sheraz arshad sheraz arshad - 1 month ago 5
jQuery Question

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";


});


This code works fine and selects elements with multiple classes. But if I select it with 'well answers-list radio-list' omitting the last 'array2' class then it gives error. It's my requirement to omit the last class to be able to select other elements too.
Is there a way to do it?

Thanks

Answer

Question is very vague and doesn't explain exactly what you are trying to do but you probably want something like:

 $(this).find("tr.well.answers-list.radio-list").filter(function(){
      if($(this).hasClass('array2')){
           st+="inside array";
      }else{
            st+="not array";
      } 
 });
Comments