Finding Elements That Contain Some Specific Text With JQuery

Posted by Weston Ganger on April 19, 2016

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:

Posted in Javascript and Tagged with jquery javascript 

Need help on your next project or application?

I specialize in Ruby-on-Rails, AngularJS, Javascript, Bootstrap, and Hybrid Mobile Apps with Cordova & Ionic.

Contact Me

Recommended Posts