Reputation:
Is there anyway I can get all of the <a>
in a page, I want to apply a new targets to all of them.
Upvotes: 3
Views: 441
Reputation: 561
Using purely Javascript DOM:
var links = document.getElementsByTagName("a");
You can check out reference at: http://www.javascriptkit.com/domref/elementmethods.shtml
Upvotes: 0
Reputation: 13031
I believe this will do what you need:
document.getElementsByTagName("A");
Upvotes: 0
Reputation: 321776
You can use
document.links
or in jQuery
$('a')
or in DOM
document.getElementsByTagName('a')
Upvotes: 12
Reputation: 9801
If I recall correctly, the prototype library has something like this...
Upvotes: -2