Check if element contains any of the class from array

后端 未结 6 1020
一整个雨季
一整个雨季 2021-01-17 06:28

I have the following elements:

6条回答
  •  囚心锁ツ
    2021-01-17 07:11

    var obj = ['nine', 'ten', 'eleven'];
    var divs =[];
    $.each(obj,function(key,value){
    
      var values = value;
      $(div).each(function(){
      var divId = $(this).attr('id');  // Giving some separate id for the div to track it
      var getClass = $(this).attr('class');
    
      if(getClass.indexOf(values) >= 0) {
        div.push("divId");
      }
     });
    });
    

    You can loop through the elements and the the result

提交回复
热议问题