98
rated 0 times
[
104]
[
6]
/ answers: 1 / hits: 24981
/ 11 Years ago, wed, october 23, 2013, 12:00:00
I am having trouble removing spaces from a string. First I am converting the div to text();
to remove the tags (which works) and then I'm trying to remove the " 
" part of the string, but it won't work. Any Idea what I'm doing wrong.
newStr = $('#myDiv').text();
newStr = newStr.replace(/ /g, '');
$('#myText').val(newStr);
<html>
<div id = "myDiv"><p>remove space</p></div>
<input type = "text" id = "myText" />
</html>
More From » jquery