jQuery attribute selector: anything but not ending

2020-07-03 09:26发布

问题:

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.

回答1:

Something along the lines of

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

Should do the trick!

Edit: alternatively

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


回答2:

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

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

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



回答3:

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

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



回答4:

Try:

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