css - jQuery show elements with specific class -
css - jQuery show elements with specific class -
i display elements within ul have class .active using jquery.
would code this?
if ($(this).hasclass('active')) { $( ".active" ).show(); }
my html markup
<ul> <li><a>menu item 1</a></li> <li class="active"><a>menu item 2</a> <ul> <li><a>menu item 2.1</a></li> <li class="active"><a>menu item 2.2</a> <ul> <li><a>menu item 2.2.1</a></li> <li class="active"><a>menu item 2.2.2</a></li> <li><a>menu item 2.2.3</a></li> </ul> </li> <li><a>menu item 2.3</a></li> </ul> </li> <li><a>menu item 3</a></li> </ul>
my css
ul li ul { display: none; overflow: hidden; }
could easier like:
$( "ul .active" ).show()
jquery css show
Comments
Post a Comment