<ul id="attached_deals_tab" class="nav nav-tabs">
<li class="active">
<a data-toggle="tab" href="#Test1">Test1</a>
</li>
<li class="">
<a data-toggle="tab" href="#Test2">Test2</a>
</li>
</ul>
With a jquery like this, I could say get me all list items:
$('#attached_deals_tab li');
But how can I say show me only the li
that has class="active"
? In one line please.
I know how to negate it:
$('#attached_deals_tab li:not(.active)');
But not the other way around...
Classes (i.e. classnames) are used for styling the li element. Multiple classnames are separated by a space. JavaScript uses classes to access elements by classname.
$('li a'). click(function() { $('li a'). removeClass('selected'); $(this). addClass('selected'); });
$('#attached_deals_tab li.active');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With