如何在table的<td>中限制显示的字数
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>截取字符串</title>
<script>
function cutStr(len){
var obj=document.getElementById('table1').getElementsByTagName('td');
for (i=0;i<obj.length;i++){
obj[i].innerHTML=obj[i].innerHTML.substring(0,len)+'…';
}
}
</script>
</head>
<body onload="cutStr(10)">
<table id="table1" style="border:1px solid #ccc; font-size:12px;">
<tr>
<td>11111111111111111111111</td><td>2222222222222222222</td>
</tr>
<tr>
<td>3333333333333333333333</td><td>444444444444444444444</td>
</tr>
</table>
</body>
</html>