Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get all <a> elements in a page using javascript

Is there anyway I can get all of the <a> in a page, I want to apply a new targets to all of them.


1 Answers

You can use

document.links

or in jQuery

$('a')

or in DOM

document.getElementsByTagName('a')
like image 70
Greg Avatar answered May 24 '26 17:05

Greg



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!