Find text in jquery

Here we will see how can we find text in jquery using ":contains" selector.
Below is our HTML,
 
<div>One Two</div>
<div>Three Four</div>
<div>Two Four Five Six</div>
 
We will now change the background of the div's having Two in it using below code,
 
$( "div:contains('Two')" ).css( "background-color", "green" );
 
 
 
Author: 

Add new comment