Friday, 15 January 2010

jquery - Target all Divs with Certain Style -


How can I target all the divs in a page, including margin-left: -15px; Margin-right: -15px; And assign margin: 0, without knowing the name of the class?

I was thinking that I div [style = "margin-left: -15px;"] [style = "margin-right: -15px;"] but this Does not work because the styles are not implemented inline.

The only option is to iterate through all the elements, obtain margins and compare values.

  var allElements = $ ("*"); For (var e = all elements lang -1; e & gt; = 0; e -) {var elem = allElements.eq (e); If (elem.css ("margin-left") == "-15px") {// do something}}  

No comments:

Post a Comment