Friday 15 February 2013

Use .addClass() on all elements jQuery -


I am trying to add a class for all the tags after an element. This means that I do not want to add a class to all IMG tags, but only those who appear after "trow 1"

  & lt; Td class = "trow1" & lt; Img src = "somesite.com" & gt; & Lt; / TD & gt; & Lt; Td square = "tro1" & lt; Img src = "somesite.com" & gt; & Lt; / TD & gt;   

I can do this:

  $ ("td.trow1"). Find ('IMG'). AddClass ('myClass');   

But this will only add the class to the first IMG-tag.

It seems that there may be a problem with some malformed HTML.

$ ("td.trow1"). ('IMG') search ('IMG') is the 'preferred' way to load your selectors because it actually works more than filling it in a selector call (due to a seal engine that parsing a regedx Is required).

No comments:

Post a Comment