如何在 jQuery 中 select 具有多个 类 的元素?
How to select an element with multiple classes in jQuery?
$(this).find("tr[class='well answers-list radio-list array2']").filter(function(){
st+="inside array";
});
此代码工作正常,selects 元素具有多个 classes。但是如果我 select 它与 'well answers-list radio-list' 省略最后一个 'array2' class 然后它给出错误。我要求省略最后一个 class 以便也能够 select 其他元素。
有办法吗?
谢谢
问题非常含糊,没有准确解释你想做什么,但你可能想要这样的东西:
$(this).find("tr.well.answers-list.radio-list").filter(function(){
if($(this).hasClass('array2')){
st+="inside array";
}else{
st+="not array";
}
});
$(this).find("tr[class='well answers-list radio-list array2']").filter(function(){
st+="inside array";
});
此代码工作正常,selects 元素具有多个 classes。但是如果我 select 它与 'well answers-list radio-list' 省略最后一个 'array2' class 然后它给出错误。我要求省略最后一个 class 以便也能够 select 其他元素。 有办法吗?
谢谢
问题非常含糊,没有准确解释你想做什么,但你可能想要这样的东西:
$(this).find("tr.well.answers-list.radio-list").filter(function(){
if($(this).hasClass('array2')){
st+="inside array";
}else{
st+="not array";
}
});