Get all <a> elements on a page using javascript

In any case, I can get everything <a>on the page, I want to apply all new goals to them.

+3
source share
5 answers

you can use

document.links

or in jQuery

$('a')

or in the DOM

document.getElementsByTagName('a')
+12
source

if you use jQuery:

$("a").attr("target","_blank")
+1
source

, , :

document.getElementsByTagName("A");
0

Javascript DOM:

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

: http://www.javascriptkit.com/domref/elementmethods.shtml

0

, - ...

-2

Source: https://habr.com/ru/post/1715454/


All Articles