Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - multiple :not selector

I'm trying to target page-wide links that do not start with a '#' and do not include in-line javascript but I'm having problems figuring out how to structure the selector properly.

Based on what I've googled about multiple selectors this should work, both selectors work independently, just not together!

$('a:not([href*=javascript]), a:not([href^=#])') .each(function(){... 
like image 337
Hill79 Avatar asked Aug 22 '11 08:08

Hill79


People also ask

Can we use multiple selectors in jQuery?

You can specify any number of selectors to combine into a single result. This multiple expression combinator is an efficient way to select disparate elements. The order of the DOM elements in the returned jQuery object may not be identical, as they will be in document order.

Can I use not in jQuery?

jQuery :not() SelectorThe :not() selector selects all elements except the specified element. This is mostly used together with another selector to select everything except the specified element in a group (like in the example above).

What is multiple selector?

You can specify any number of selectors to combine into a single result. This multiple expression combinator is an efficient way to select disparate elements. The order of the DOM elements in the returned jQuery object may not be identical, as they will be in document order. An alternative to this combinator is the .


1 Answers

Try using

$('a:not([href*=javascript]):not([href^=#])') ... 
like image 106
jtbandes Avatar answered Sep 22 '22 17:09

jtbandes