Reputation: 447
I use the following code to select all external links on the page
items = jQuery("a[href^=\'http:\']").not("[href*=\'" + window.location.host + "\']");
But I need to exclude links from tags with some known classes, e.g. I want to exclude "class1" and "class4" and select whatever have left.
<body>
<div>
<p class="class1">
<span class="class2"><a href="#">link</a></span>
<span class="class2"><a href="#">link</a></span>
</p>
</div>
<p class="class3"><a href="#">link</a></p>
<div class="class4"><a href="#">link</a></div>
<a href="#">link</a>
</body>
Thanks in advance
Upvotes: 0
Views: 1467
Reputation: 46440
Html elements can have multiple classes by seperating each class name with a space. Is it not possible to just add an additional class name to the elements you want to select, and not add it to the ones you don't want to select?
Upvotes: 1