Trim white space/tab between two element?

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


使用:

function specialTrim(str){
    return str.replace(/>s+</g,'><');
}

你可以在filter()中使用contents()来匹配你的<tr>元素中的文本节点:

$("tr").contents().filter(function() {
    return this.nodeType == 3;
}).remove();
链接地址: http://www.djcxy.com/p/27510.html

上一篇: 如何删除字符串中的重复空格?

下一篇: 修剪两个元素之间的白色空间/选项卡?