javascript - find an element by style with jquery -


How can I get an element in an HTML document, whose style is the property? Here's an example:

HTML:

  & lt; Ul & gt; & Lt; Li style = 'z-index = 1;' & Gt; E1 & lt; / Li & gt; & Lt; Div style = 'z-index = 8;' & Gt; Div & lt; / Div & gt; & Lt; Li style = 'z-index = 2;' & Gt; E2 & lt; / Li & gt; & Lt; Li style = 'z-index = 3;' & Gt; E3 & lt; / Li & gt; & Lt; Li style = 'z-index = 4;' & Gt; E4 & lt; / Li & gt; & Lt; Li style = 'z-index = 5;' & Gt; E5 & lt; / Li & gt; & Lt; Ul & gt;   

The question is how do I choose, for example:

  • z-index = 4 . And how to select all with div to z-index = 8 ...

    If the style is set to inline, you can use an attribute selector:

      $ ('li' [style * =" z-index : 4 "] ') // z-index = 4   

    . The advantage of this method is that it is very fast.

    If the style is set through the stylesheet, then you can access it like this:

      var elem; Var elems = $ ("li"); For (var i = 0; i & lt; elems.length; i ++) {if ($ (elems [i]). CSS ('z-index') == '4') {elem = elems [ I]; // Assignment we found to be inattentive; // exit loop start}}   

    note webkit browser, (safari, chrome, etc.), unless this situation is in the z-index The neck will not return the well. See it

    In addition to this, there is still to loop. Filter ()

  • Comments

    Popular posts from this blog

    excel vba - How to delete Solver(SOLVER.XLAM) code -

    github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

    ios - Replace text in UITextView run slowly -