一个取字符的问题!在线等...
有一个表格,里面规则的排列着几行信息,我想把里面的每行信息用一个循环语句读取出来,用for each in读不出来,请大家帮忙。
例子:
<tr>
<td height= "25 "> ·1 </td>
<td> 500 </td>
<td> 查看 </td>
</tr>
<tr>
<td height= "25 "> ·2 </td>
<td> 1532 </td>
<td> 查看 </td>
</tr>
<tr>
<td height= "25 "> ·3 </td>
<td> 1000 </td>
<td> 查看 </td>
</tr>
<tr>
<td height= "25 "> ·4 </td>
<td> 100 </td>
<td> 查看 </td>
</tr>
我想把行里的三个数据取出来,用循环一个一个的取,请大家提示下怎么写!
------解决方案--------------------这段是一个字符串还是已经输出的HTML要用脚本来操作?
------解决方案-------------------- <html>
<body>
<table>
<tr>
<td height= "25 "> ·1 </td>
<td> 500 </td>
<td> 查看 </td>
</tr>
<tr>
<td height= "25 "> ·2 </td>
<td> 1532 </td>
<td> 查看 </td>
</tr>
<tr>
<td height= "25 "> ·3 </td>
<td> 1000 </td>
<td> 查看 </td>
</tr>
<tr>
<td height= "25 "> ·4 </td>
<td> 100 </td>
<td> 查看 </td>
</tr>
</table>
<p> 结果: </p>
<script>
var tr = document.getElementsByTagName( "tr ");
for (var i = 0 ; i < tr.length; i++){
for(var j = 0; j < tr[i].childNodes.length; j++){
document.write (tr[i].childNodes[j].firstChild.nodeValue + "- ");
}
document.write ( " <br /> ");
}
</script>
</body>
</html>
------解决方案--------------------dim a
a = " <tr> "
a = a & " <td height= " "25 " "> ·1 </td> "
a = a & " <td> 500 </td> "
a = a & " <td> 查看 </td> "
a = a & " </tr> "
a = a & " <tr> "
a = a & " <td hei