2

我怎样才能从这样的表中获取href?

<table class="file_slot" cellpadding=0 cellspacing=3>
<tr>*****************</tr>
<tr>
        <td><b>Size:</b></td>
        <td>452<small><a href="http://www.google.com">Google</a></small></td>
     </tr>

我尝试使用 getElementsByClassName 但我没有找到<a>标签。

提前致谢

4

3 回答 3

5

你可以做

var href =  document.querySelector('.file_slot a').href;
于 2013-07-15T10:36:18.320 回答
3

你想要getElementsByTagName代替:

var aTags = document.getElementsByTagName("a");

于 2013-07-15T10:35:49.927 回答
2

尝试

var file=  document.querySelector('.file_slot a');
file.href="http://www.google.com";
于 2013-07-15T10:37:57.970 回答