Dennis Berg
Dennis Berg

Reputation: 201

jQuery attribute selector: anything but not ending with specified string?

I need to select elements in jquery, attibute values of which do not end with a specified substring.

It must be an equivalent to "match all elements but those that end with a given substring in that attribute".

So that e[a!@#=finstr] matches e, e a="finstring" etc, and does NOT match e a="somethingfinstr", e a="finstr".

Help, thanks.

Upvotes: 17

Views: 10000

Answers (4)

Willem Mulder
Willem Mulder

Reputation: 13994

Something along the lines of

$(':not([name$="finstr"])')

Should do the trick!

Edit: alternatively

$(selector).not('[name$="value"]');

Upvotes: 26

idm
idm

Reputation: 1748

Try:

$('*').not('[attribute$="finishstring"]') 

Upvotes: 0

Drejc
Drejc

Reputation: 14286

Try inverting the: Attribute Ends With Selector [name$="value"]. with jQuery(':not(selector)').

Something like this: :not([name$="value"])

Upvotes: 1

ipr101
ipr101

Reputation: 24236

I think this would work, using links as an example -

$("a:not([id$='hello'])"

Demo - http://jsfiddle.net/CJH2M/

Upvotes: 2

Related Questions