Monday, 15 March 2010

javascript - Apply class to parents of child apart from the one selected - JQuery -


I am trying to apply a class to each parent element other than my child.

  $ ('. MyChildName'). Parents ('. MyParentName'). ToggleClass ("applystyle");  

This applies to a class I have chosen, I want to apply it to each parent on APART. I believe I can not use the selector, but it wants to work.

Thank you.

You can get all .myParentName , then the current parent

  $ ('. MyParentName'). ('. MyChildName'). ('MyParentName') instead of $ ('.mychildName'). Parents ()  

There is another way

  $ ('. MyParentName: No (: (mychildName))'. Toggleclass ("applystyle");  
< / Html>

No comments:

Post a Comment