jquery - loop through text and replacing * with span -


i struggling script should replace text , make bold via css.

but problem is, script isn't looping. takes first text.

can me out?

here's my fiddle.

and here's code

$(document).ready(function (i) { $('.main:contains("*")').each(function () {     $(this).html($(this).html().replace('*', '<span class="highlight">'));     $(this).html($(this).html().replace('*', '</span>')); }); 

});

this 1 trick:

$(document).ready(function (i) {     function replace(o) {         $(o).html($(o).html().replace('*', '<span class="highlight">'));         $(o).html($(o).html().replace('*', '</span>'));         if ($(o).html().indexof("*") >= 0) {             replace(o);         }     }     replace('.main:contains("*")');  }); 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -