开发者

jQuery conflicts with Scriptaculous

WHY is it that i cannot use Scr开发者_StackOverflowiptaculous and jQuery in the same page without calling: jQuery.noConflict() ?


Because they both use the $ variable in the global namespace.


You can use $ in the following scenario:

<script>
 jQuery.noConflict();

 // Put all your code in your document ready area
 jQuery(document).ready(function($){
   // Do jQuery stuff using $
   $("div").hide();
 });

 // Use Prototype with $(...), etc.
 $('someid').hide();
</script>

I think it's the best way of using libraries which had the same $ function


WHY is it that i cannot use Scriptaculous and jQuery in the same page without calling: jQuery.noConflict() ?

If you were able to use different javascript libraries on same page, the very existence of jQuery.noConflict() was not needed. It is because of special symbol $ which holds special meaning in those different javascript libraries.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜