Finding Elements That Contain Some Specific Text With JQuery

Posted By Weston Ganger

I wanted to search the DOM for a specific piece of text.

Turns out this is super simple with the javascript contains selector

# Search all elements
$(":contains('some text')");

# Search only p elements
$("p:contains('some text')");

Good ol jQuery to the rescue!

Related External Links:

Article Topic:Software Development - Javascript

Date:April 19, 2016