Possible Duplicate:
Remove non breaking space ( ) from between elements using jquery
How to write a script to trim white space/tab between two element?
For example,
<tr> <td>A </td> <td>B </td> <td>C </td> </tr>
Convert to,
<tr><td>A </td><td>B </td><td>C </td></tr>
For the example, the script should remove the white space/tab between first <td>xxx</td> element and second <td>xxx</td> element and so on.
Thanks
Use:
function specialTrim(str){
return str.replace(/>\s+</g,'><');
}
You can use contents() with filter() to match the text nodes inside your <tr> element:
$("tr").contents().filter(function() {
return this.nodeType == 3;
}).remove();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With