Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery, selecting what does NOT contains something

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"?

like image 500
user1722791 Avatar asked Dec 24 '12 13:12

user1722791


People also ask

How do you check does not contain jQuery?

Use the :not() CSS selector.

How do I select not this in jQuery?

jQuery :not() SelectorThe :not() selector selects all elements except the specified element. This is mostly used together with another selector to select everything except the specified element in a group (like in the example above).

Is not condition in jQuery?

jQuery not() Method: This method returns elements that do not match a defined condition. This method specifies a condition. Elements that do not match the condition are returned, and those that match will be removed. Mostly this method is used to remove one or more than one elements from a group of selected elements.

How use contains in jQuery?

jQuery :contains() SelectorThe :contains() selector selects elements containing the specified string. The string can be contained directly in the element as text, or in a child element. This is mostly used together with another selector to select the elements containing the text in a group (like in the example above).


2 Answers

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

like image 199
Ricardo Marimon Avatar answered Sep 28 '22 22:09

Ricardo Marimon


$('tr').not(':contains("pc")') 
like image 39
Chuck Norris Avatar answered Sep 28 '22 22:09

Chuck Norris