Reputation: 267
I have a dynamic list that looks something like this
<li>item 1</li>
<ii>item 2</li>
<ii class="route2">item 2</li>
<ii>item 3</li>
<ii>item 4</li>
and two buttons
<button>Route one</button>
<button>Route two</button>
I can't work how to show the route two button only if all list items have the route2 class.
Upvotes: 1
Views: 81
Reputation: 145378
One possible way:
$("button:eq(1)").toggle( !$("li:not(.route2)").length );
DEMO: http://jsfiddle.net/CNP7Z/
Upvotes: 3
Reputation: 3517
This should work:
if ( $('li').not('.route2').length ){
$('button').hide();
}
Upvotes: 1