<table id="testtable">
<tbody>
<tr>
<td>
<div style="width:10px;height:10px;border:1px solid black""> </div>
</td>
<td>
<div style="width:10px;height:10px;border:1px solid black"> </div>
</td>
</tr>
<tr>
<td>
<div style="width:10px;height:10px;border:1px solid black"> </div>
</td>
<td>
<div style="width:10px;height:10px;border:1px solid black"> </div>
</td>
</tr>
</tbody>
</table>
IE下发现
jquery 1.3 $("div").text().length>0 text()使用nodeValue取值
jquery 1.7 $("div").text().length=0 text()使用innerText取值
$("#testtable tr td").click(function(){
$div=$(this).find("div");
<!--在IE下 对于  nodeValue与innerText输出结果不同 FireFox不支持innerText-->
$div.each(function(){
var nt=this.childNodes[0].nodeType;
var nv=this.childNodes[0].nodeValue;alert("使用1.7.2 $.trim----"+$.trim(nv).length);<!--输出0 -->
alert("使用1.3 $.trim----"+$.trim(nv).length);<!--输出1 -->
alert(nv.replace(/^\s+|\s+$/g, "").length);alert(/^\s+|\s+$/g.test(nv));<!--IE下false FF下true -->
if(typeof this.innerText!="undefined"){
alert(this.innerText.replace(/^\s+|\s+$/g, "").length);
alert(/^\s+|\s+$/g.test(this.innerText));
}});
<!--IE doesn't match non-breaking spaces with \s-->
rtrim = /\S/.test("\xA0") ? (/^[\s\xA0]+|[\s\xA0]+$/g) : /^\s+|\s+$/g, //'\xA0'为 的ascii扩展码 http://www.ascii-code.com/
下面是1.7版本对$.trim()的解释,用的就是上面rtrim的正则表达式<!--The $.trim() function removes all newlines, spaces (including non-breaking spaces), and tabs from the beginning and end of the supplied string.
If these whitespace characters occur in the middle of the string, they are preserved.-->
<!--早期版本的$.trim() 不支持non-breaking spaces
jquery 1.3.2
trim : function(E) {
return (E || "").replace(/^\s+|\s+$/g, "")
},
-->