I have html like this.
<td id="foo">
<img src="foo.png" /> <img src="foo.png" /> <img src="foo.png" />
</td>
The HTML above contains whitespace and also ,
I want to remove that using jQuery.
How to do that?
already tried with this script but not work.
$('#foo').text().replace(/ /g,'');
I think you need to use contents() and then filter out all the textNodes that is a plain space
something like that maybe? if you only got images then you can just remove
&& this.data == " "partI have edited it looks for spaces and now, jsfiddle test: http://jsfiddle.net/Rurn2/