Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery selector question. Select all nodes that do NOT START with (string)

Tags:

People also ask

How do I select not this 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).

Can you select multiple elements in jQuery?

In jQuery, you can select multiple elements by separate it with a comma “,” symbol.


Trying to assemble a rather complex jQuery selector here, and having trouble.

Essentially, I'm trying to grab all anchors that that 1) do not have a "rel" of "facebox", and OR 2) do not have an "href" that begins with "mailto".

This is what I've been trying to do:

$('a[rel!=facebox], a[href!^="mailto"]') 

Small variations of this don't seem to work. Is there some better way of going about this?

These selectors seem to work individually, but not when sitting consecutively in the same selector:

$('a:not([rel=facebox]), a:not([href^=mailto])') 

Final solution: We have a winner!

$('a:not([rel=facebox],[href^=mailto])')