JQuery, selecting what does NOT contains something
Asked Answered
L

4

34

If i want to select what contains "pc" i use $('tr:contains("pc")')

But what can i use to select what does NOT contains "pc"?

Ladykiller answered 24/12, 2012 at 13:49 Comment(0)
R
61

Use the :not() selector that is part of the jquery framework. Something like $('tr:not(:contains("pc"))') should do the trick.

Roeser answered 24/12, 2012 at 13:50 Comment(2)
This is the one that I ended up using, thanks a lot. Actually, I cheated :3 I was not using Jquery, but phpquery, and I was having problems using the .not function.Ladykiller
:not is actually standard css. It's :contains that's jquery specific.Peipus
T
5
$('tr').not(':contains("pc")')
Tracey answered 24/12, 2012 at 13:51 Comment(0)
W
2
$('tr:not(:contains("pc"))') // this can be used
Wolfsbane answered 24/12, 2012 at 13:51 Comment(0)
M
0

$("tr:not(:contains("pc"))")

if you use simple quotes with double quotes mixed in the same sentence, it doesn't work

Millerite answered 11/5, 2016 at 8:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.