JavaScript
Article
By Sam Deering

jQuery :Contains() Selector Examples

By Sam Deering

It can be written as words or inside parentheses for example this contains function finds all the divs containing the word “jquery4u” and underlines it.

$("div:contains('jquery4u')").css("text-decoration", "underline");
--ADVERTISEMENT--

Advanced example jQuery :Contains() Example 2

For this example this contains function finds all the paragraphs containing the word “jquery4u” and converts them to hyperlinks linking to the jquery4u blog.

var parag = $("p:contains('jquery4u')");
for(var i = 0; i $&");
Recommended
Sponsors
The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account