老字号餐厅将福寿螺当田螺卖 官方称已立案调查
时间:2024-09-11 09:24:02
<script type="text/javascript">
jQuery(function(){ //直接使用 jQuery ,沒有必要調(diào)用"jQuery.noConflict()"函數(shù)。
jQuery("p").click(function(){
alert( jQuery(this).text() );
});
});
$("pp").style.display = 'none'; //使用prototype
</script>
</body>
</html>
二、jQuery庫在其他庫之后導(dǎo)入,使用jQuery.noConflict()方法將變量$的控制權(quán)讓渡給其他庫,有以下幾種方式:
<script type="text/javascript"> jQuery.noConflict(); //將變量$的控制權(quán)讓渡給prototype.js jQuery(function(){ //使用jQuery jQuery("p").click(function(){ alert( jQuery(this).text() ); }); }); $("pp").style.display = 'none'; //使用prototype </script> //代碼二 <script type="text/javascript"> var $j = jQuery.noConflict(); //自定義一個比較短快捷方式 $j(function(){ //使用jQuery $j("p").click(function(){ alert( $j(this).text() ); }); }); $("pp").style.display = 'none'; //使用prototype </script> //代碼三 <script type="text/javascript"> jQuery.noConflict(); //將變量$的控制權(quán)讓渡給prototype.js jQuery(function($){ //使用jQuery $("p").click(function(){ //繼續(xù)使用 $ 方法 alert( $(this).text() ); }); }); $("pp").style.display = 'none'; //使用prototype </script> //代碼四 <script type="text/javascript"> jQuery.noConflict(); //將變量$的控制權(quán)讓渡給prototype.js (function($){ //定義匿名函數(shù)并設(shè)置形參為$ $(function(){ //匿名函數(shù)內(nèi)部的$均為jQuery $("p").click(function(){ //繼續(xù)使用 $ 方法 alert($(this).text()); }); }); })(jQuery); //執(zhí)行匿名函數(shù)且傳遞實參jQuery $("pp").style.display = 'none'; //使用prototype /*********************************************************************/ jQuery(document).ready(function(){ //一加載頁面的時候就將權(quán)利讓出去 jQuery.noConflict(); }); </script>
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
本文如未解决您的问题请添加抖音号:51dongshi(抖音搜索懂视),直接咨询即可。