jQuery: How to remove CSS class from both parent and its direct child? -



jQuery: How to remove CSS class from both parent and its direct child? -

$("#menu-main > li").add("#menu-main > li > a").removeclass("hover").find("div").hide(); <ul id="menu-main"> <li class="hover"> <a class="hover" href="" title="">abc</a> <div> <ul> <li><a href="" title="">xyz</a><li> </ul> </div> </li>

this works thought write improve please or must repeat "#menu-main > li" add() part?

$("#menu-main > li").add("#menu-main > li > a").removeclass("hover")

that works, alternatively can use

$("#menu-main > li").children('a').andself().removeclass("hover")

jquery

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -