jquery - How to use JavaScript or CSS to change a string on a page -
how utilize javascript or css alter string on page.
i have around 50 elements contain tags separated commas ie
<a name="tagslist">skrillex, dubstep, dance</a>
i want using javascript take each of these words , style them differently don't separated commas on different lines. problem there can variable amount of tag lists on page.
is there way can accomplish easily?
$('a[name="tagslist"]').html(function(_, html){ var arr = [], tags = html.split(/\s*,\s*/); (var i=0; i<tags.length; i++) arr.push('<div class="whatever">' + tags[i] + '</div>'); homecoming arr.join(''); });
javascript jquery html
No comments:
Post a Comment