javascript - Wrapping a split string's substrings in an element -
how use javascript/jquery select $('td.created') , split html on <br>, wrap each section in span tags (so can add class span:first in order style it).
the format of string returned $('td.created').html() like
posted user123 <br> posted on 1/2/12 @ 4:15pm
possible universal solution (works not 2 lines):
$("td.created").each(function() { var text = this.innerhtml.split("<br>"); (var = 0; < text.length; i++) { var span = $("<span />").html(text[i]); if (i == 0) span.addclass("first"); span.appendto("#element"); } });
Comments
Post a Comment