首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

怎么取得 网页表格内的 链接地址

2013-10-31 
如何取得 网页表格内的 链接地址table classgrid0tbodytrtd aligncenter nowrapnowrap张

如何取得 网页表格内的 链接地址
<table class="grid0">
<tbody>
<tr>

<td align="center" nowrap="nowrap">张三    </td>
<td align="center" nowrap="nowrap"><a href="http://10.14.101.251:8080/has/Out.action?op=cardetail">学号</a></td>
<td align="center" nowrap="nowrap">5</td>
<td align="center" nowrap="nowrap">sss</td>
   <td align="center" nowrap="nowrap"><a href="http://102.145.101.251:8080/has/car_audit/CarAudit%21Wetail.action?tht=36.35&amp;x_carId=138&amp;op=wetail">36.35</a></td>
<td align="center" nowrap="nowrap">4</td>
<td align="center" nowrap="nowrap">14</td>
<td align="center" nowrap="nowrap">
<a align="center" nowrap="" href="http://10.14.111.60:8081/image/ANE.JPG" target="_blank">原图<br></a>
</td>

</tr>
</tbody>
</table>


想要的是:  指向“原图”的地址 "http://10.14.111.60:8081/image/ANE.JPG"
[解决办法]

<table class="grid0">
<tbody>
<tr>

<td align="center" nowrap="nowrap">张三    </td>
<td align="center" nowrap="nowrap"><a href="http://10.14.101.251:8080/has/Out.action?op=cardetail">学号</a></td>
<td align="center" nowrap="nowrap">5</td>
<td align="center" nowrap="nowrap">sss</td>
    <td align="center" nowrap="nowrap"><a href="http://102.145.101.251:8080/has/car_audit/CarAudit%21Wetail.action?

tht=36.35&amp;x_carId=138&amp;op=wetail">36.35</a></td>
<td align="center" nowrap="nowrap">4</td>
<td align="center" nowrap="nowrap">14</td>
<td align="center" nowrap="nowrap">
<a align="center" nowrap="" href="http://10.14.111.60:8081/image/ANE.JPG" target="_blank">原图<br></a>
</td>

</tr>
</tbody>
</table>

<script>
table=document.getElementsByTagName('table')[0];
as=table.getElementsByTagName('a');
var href='';
for(var i=0;i<as.length;i++){
   if(as[i].innerHTML.indexOf('原图')==0){href=as[i].href;break;}
}

alert(href)
</script>

热点排行