Find/Modify Specific Text


/ Published in: jQuery
Save to your folder(s)

Find any instances of certain text in an element and modify it.


Copy this code and paste it in your HTML
  1. $("#main-div").html(function(i,text){
  2. return text.replace("keyword", function(match){
  3. return '<span class="red">' + match + '</span>';
  4. });
  5. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.