jqueryexample.com JQuery - match text string - jqueryexample.com

JQuery – match text string by jqueryuser

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>
Did you like this? Share it:

Discussion

No comments yet, be the first.

Leave a Comment