jQuery Content Filter Selectors
Last Updated Jul 21, 2015, 12:00:06 PM
jQuery contains() selector
contains
selector selects all elements
which contain the specified text in HTML
.
The below example underlines the names which contain Gates asHTML
text in it
Try It Now
jQuery :empty Selector
empty selector
selects all HTML
elements that have no children (including text nodes).
The below example finds all elements that are empty - which doesn't have any child elements or text.
It will select all the empty table columns and add Empty text in that fileds also it changes the background to red
OutputTry It Now
jQuery has() Selector
has selector
, Selects elements the HTML
elements which contain at least one element that matches the specified selector or given condition.
The below example adds blue border to the div
element which has a paragraph of text
In the above example HTML
code, we have fourdiv
elements. Among the four div elements only first and third div elements has paragraphs. So the blue border will be applied to those two div
elements only
Try It Now
jQuery :parent Selector
jQuery parent
selector is used to select the elements which have at least one child
element
parent
selector is used to select the elements which have at least one child
elementNote, that the a parent element should have at least one child element
SyntaxThis is the inverse of jquery empty
Finds all td
elements with children, including text.
Try It Now
Other Advanced jQuery Selectors you might want to learn
jQuery Complete Selectors ReferencejQuery Selectors
jQuery Basic Selectors
jQuery Child Selectors
jQuery Content Filter Selectors
Sources and Credits
The content and methods in the tutorial has been referred and updated with jQuery API and The jQuery Foundation
Last Updated Jul 21, 2015, 12:00:06 PM
Learning 200 jQuery Functions with 800 Examples -Udemy
Learn jQuery in One Month - from OneMonth
The Ultimate Web Development Course -Udemy
Learn jQuery: An In-depth Course For Beginners -Udemy