What is the difference between "jQuery(selector)" and "$(selector)"? [duplicate]
Possible Duplicate:
What is the difference between $ and jQuery
I've noticed cases where "jQuery(selector)" is used instead of "$(selector)", what is the d开发者_JAVA百科ifference between both of any?
None. Normally, the $ variable simply points to jQuery. You might be using jQuery instead in cases where the $ is used by another library, or you are using it for other purposes in your code.
None. $ is merely an alias to jQuery. However, when developing code for public consumption, you should use jQuery instead of $, as $ might be assigned to something else, if they use more than one framework. Or just use a closure to make $ a private variable, which is what most plugins do:
(function($){
// Use $ normally here...
})(jQuery);
Its just an alias for the same thing - to avoid conflicts in something like Wordpress, or frameworks that might import their own version of jQuery.
jQuery is used when you have another javascript library that uses the $ variable. jQuery===$
加载中,请稍侯......
精彩评论