Skip to content

jQuery: Search String Inside DIV tag

let say..you want to modify/add style inside DIV tag contains “Jhon” string

below example the code

<div>John Resig</div>
<div>George Martin</div>
<div>Malcom John Sinclair</div>
<div>J. Ohn</div>
<script>
$( "div:contains('John')" ).css( "text-decoration", "underline" );
</script>

Results:

John Resig
George Martin
Malcom John Sinclair
J. Ohn

Share

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.