17

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.

4 Answers 4

27

Something along the lines of

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

Should do the trick!

Edit: alternatively

$(selector).not('[name$="value"]');
Sign up to request clarification or add additional context in comments.

2 Comments

I guess you have you wrap name$="finstr" in [ ]
But if I have a class '.editable:not([name$=".notthis"]) - I wonder what change is needed to get it to work
2

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

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

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

Comments

1

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

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

Comments

0

Try:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.