JQuery – match text string

Using jQuery contains method we can easily get the string element.

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function() {
$('*:contains("My simple string")').each(function(){
     if($(this).children().length < 1)
          $(this).css("color","#ff0000") });
<p> Hello world </p>
<p>My simple string</p>
Share this nice post:

7 thoughts on “JQuery – match text string

Leave a Reply

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