Is there anyway I can get all of the <a>
in a page, I want to apply a new targets to all of them.
views:
100answers:
5
A:
If I recall correctly, the prototype library has something like this...
Justin
2009-08-18 17:35:44
i'm ok with you giving the jQuery solution as long as you give the non-jQuery solution as well. unless the asker mentions jQuery, jQuery should not be used as the main answer.
geowa4
2009-08-18 17:39:28
it was just a suggestion. i was providing help that i knew.
Jason
2009-08-18 18:13:49
+12
A:
You can use
document.links
or in jQuery
$('a')
or in DOM
document.getElementsByTagName('a')
Greg
2009-08-18 17:36:37
+1 comprehensive; maybe add some help for modifying targets, even though it wasn't specifically asked for?
geowa4
2009-08-18 17:41:26
A:
I believe this will do what you need:
document.getElementsByTagName("A");
John MacIntyre
2009-08-18 17:37:41
A:
Using purely Javascript DOM:
var links = document.getElementsByTagName("a");
You can check out reference at: http://www.javascriptkit.com/domref/elementmethods.shtml
Guilherme
2009-08-18 17:38:32