Jquery Replacing Space In String With Html
Tag
I want to replace spaces in a string with a html
tag, whats the best way of doing this?. Currently I have this code which replaces the spaces with a '-'. $('.msn').ea
tag, whats the best way of doing this?. Currently I have this code which replaces the spaces with a '-'. $('.msn').ea
Solution 1:
$(".msn").html(function(i, oldHTML) {
return oldHTML.replace(/ /g, '<br/>');
});
Solution 2:
Try using .html()
instead of .text()
:
$(".msn").each(function() {
$(this).html($(this).html().replace(/ /g, '<br />'));
});
Post a Comment for "Jquery Replacing Space In String With Html
Tag"