user1059511
user1059511

Reputation: 267

If class other than my class is present

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

Answers (2)

VisioN
VisioN

Reputation: 145378

One possible way:

$("button:eq(1)").toggle( !$("li:not(.route2)").length );

DEMO: http://jsfiddle.net/CNP7Z/

Upvotes: 3

Bill
Bill

Reputation: 3517

This should work:

if ( $('li').not('.route2').length ){
    $('button').hide();
}

Upvotes: 1

Related Questions