How Do I Strip White Space When Grabbing A Text()
I have the following jquery statement. I wish to remove the whitespace as shown below. So if I have a word like: For example '#wordOperating System/test' I would like the end
Solution 1:
Try the global g
modifier:
.replace(/ /g, '')
Same goes for your slash replacement (in case there are multiple /
s in your string):
.replace(/\//g, '\\/')
Solution 2:
You can do it with one simple regex...
var x = "wordOperating System/test";
x = x.replace(/\s|\//g, '');
alert(x);
So your code will be...
$("word" + lbl.eq(i).text().replace(/\s|\//g, '')).hide();
Post a Comment for "How Do I Strip White Space When Grabbing A Text()"