1

Imagine I have the following HTML:

<div>
     <p> text 1 </p>
     .. some content ..
</div>

<div>
     <p> text 2 </p>
     .. some content ..
</div>

I want to select the divs by the content of text, is it possible ? and how can id do it ? thanks !!

1 Answers1

1

Yes possible, Try something like this

$( "div:contains('John')" ).css( "text-decoration", "underline" );
$('div:contains("test")').css('background-color', 'blue');

Same thing explained here as detail Selector

Anto king
  • 1,222
  • 1
  • 13
  • 26