I am currently learning JavaScript and the code given below does not produce results, I thought it would be : When I run this code, it writes 1 element with an array. What did I do? link is a live node list (see). Any change in the link on the page will be spread in the list immediately . With the first var link = document.getElementsByTagName ("a"); (I = 0; i & lt; links.length; i ++) for {document.write (link [i]); }
document.write you are overwriting the existing document (if used after the document is loaded), hence the
link < / Code> the list will be empty.
use console.log () instead of
document.write and javascript in your browser See Replace Console.
var link = document.getElementsByTagName ("a"); for (i = 0; i
Comments
Post a Comment