jQuery find by inline css attribute

后端 未结 8 1862
深忆病人
深忆病人 2020-12-06 00:14

I need to find an element based on a specific css attribute. The css is applied inline and I can not use a class. Is there anyway to achieve this i

相关标签:
8条回答
  • 2020-12-06 00:38
    var ccsStyle="font-weight:bold";
    var els = [];
    $("*").each(function(){
      var st = $(this).attr("style");
      if(st.indexOf(cssStyle) > -1) els.push(this);
    });
    //do stuff with els
    
    0 讨论(0)
  • 2020-12-06 00:45

    You could use the attribute flag and use contains if you know the specific format that it's in.

    $("[style*='position']")
    

    This would find all the elements that define the position css attribute.

    0 讨论(0)
提交回复
热议问题