Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting element from td (Javascript)?

Tags:

javascript

How can i get the href from such a table?

<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>

I tried using getElementsByClassName but i don't get to the <a> tag.

Thanks in advance

like image 663
MNS Avatar asked Jun 03 '26 23:06

MNS


1 Answers

You can do

var href =  document.querySelector('.file_slot a').href;
like image 200
Denys Séguret Avatar answered Jun 06 '26 13:06

Denys Séguret



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!