Phillip Senn
Phillip Senn

Reputation: 47595

Using the not selector for jQuery Mobile

I do the following:

$('ul').attr('data-role','listview');

And that defaults all my unordered lists to be listviews, but I want to exclude unordered lists that are within a <nav> tag, such as:

<nav>
<ul>
<li><a href="#">One</a></li>
<li><a href="#">Two</a></li>
</ul>
</nav>

Q: How can I change my selector to not include those unordered lists that are inside of the nav element?

Upvotes: 1

Views: 42

Answers (1)

techfoobar
techfoobar

Reputation: 66663

You can filter out only those uls that are not a direct child of a nav by doing:

$('ul').not('nav > ul').attr('data-role','listview');

Upvotes: 4

Related Questions