当前位置: 代码迷 >> JavaScript >> 怎么取得 网页表格内的 链接地址
  详细解决方案

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

热度:210   发布时间:2013-10-31 12:03:52.0
如何取得 网页表格内的 链接地址
<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>
  相关解决方案