admin管理员组文章数量:1435859
My js Code
if ($("#fb_connect_sell,#fb_connect").hasClass("connected")){
}
how i can use multiple selector with single hasclass?
My js Code
if ($("#fb_connect_sell,#fb_connect").hasClass("connected")){
}
how i can use multiple selector with single hasclass?
Share Improve this question edited Oct 26, 2013 at 12:02 underscore 6,9077 gold badges43 silver badges81 bronze badges asked Oct 26, 2013 at 11:43 SadikhasanSadikhasan 18.6k23 gold badges83 silver badges126 bronze badges 2- 1 what do you want to check? whether one of the has the connected class or both has the class – Arun P Johny Commented Oct 26, 2013 at 11:49
- both class is connected or not if not then addclass for both and if yes then removeclass for both means toggle. – Sadikhasan Commented Oct 26, 2013 at 12:57
2 Answers
Reset to default 5If you want to check whether one of the elements has the class then use .is()
if ($("#fb_connect_sell,#fb_connect").is(".connected")){
}
if you want to check whether both has the class
if ($("#fb_connect_sell,#fb_connect").filter(".connected").length){
}
try
var $first = $("#fb_connect_sell");
var $second = $("#fb_connect");
if ($html.hasClass('connected') && $html.hasClass('connected')) {
// do stuff
}
本文标签: javascriptJquery multiple elements with single hasclassStack Overflow
版权声明:本文标题:javascript - Jquery multiple elements with single hasclass - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745674939a2669795.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论