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 !!

2

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.