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") });
});
</script>
<body>
<p> Hello world </p>
<p>My simple string</p>
</body>
Share this nice post:

7 thoughts on “JQuery – match text string

Comments are closed.