JQuery中$(“#id”)找不到,JQuery(“#id”)可以

jQuery(function(){
jQuery(“.articlepost”).hover(

function(){jQuery(this).addClass(“shaddow”);},

function(){jQuery(this).removeClass(“shaddow”);

});
});

其它类库也用$(“”)这样的格式,和jquery有冲突了。
jQuery()这种写法就是避免和其它类库同时使用时在用$这个东西的冲突的.代码可以这样改。
jQuery(function($){
$(“.articlepost”).hover(

function(){$(this).addClass(“shaddow”);},

function(){$(this).removeClass(“shaddow”);

});
});

本文链接:JQuery中$("#id")找不到,JQuery("#id")可以

转载声明:本站文章若无特别说明,皆为原创,转载请注明来源:Rexdf,谢谢!^^


This entry was posted in 网站建设 and tagged . Bookmark the permalink.

One Response to JQuery中$(“#id”)找不到,JQuery(“#id”)可以

Leave a Reply

Your email address will not be published.

*

:zsmilebig: :zsadbig: :zwiredbig: :zgreenhappy: more »

This site uses Akismet to reduce spam. Learn how your comment data is processed.