jQuery attribute selector: anything but not ending

2020-07-03 09:37发布

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条回答
姐就是有狂的资本
2楼-- · 2020-07-03 09:48

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

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

查看更多
Melony?
3楼-- · 2020-07-03 09:49

Try:

$('*').not('[attribute$="finishstring"]') 
查看更多
够拽才男人
4楼-- · 2020-07-03 10:06

Something along the lines of

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

Should do the trick!

Edit: alternatively

$(selector).not('[name$="value"]');
查看更多
ら.Afraid
5楼-- · 2020-07-03 10:07

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

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

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

查看更多
登录 后发表回答