0
   

im new to javascript so please explain this code

 
 
Navdeep
 
Reply Sun 14 Feb, 2016 11:16 pm
// Week05: collections.js
// Script to demonstrate using the links collection.
function processLinks()
{
var linksList = document.links; // get the document's links
var contents = "<ul>";

// concatenate each link to contents
for ( var i = 0; i < linksList.length; ++i )
{
var currentLink = linksList[ i ];
contents += "<li><a href='" + currentLink.href + "'>" +
currentLink.innerHTML + "</li>";
} // end for

contents += "</ul>";
document.getElementById( "links" ).innerHTML = contents;
} // end function processLinks

window.addEventListener( "load", processLinks, false );
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 1,364 • Replies: 0
No top replies

 
 

Related Topics

HVAC lines - Question by alevythiebaut
css - Question by keerthi60
Random Walk in Python Code - Question by Cbr600
Hacked on Facebook - Question by Hopea
need help with this code - Question by Philoue
Hide/Unhide Columns - Question by N Prakash
 
  1. Forums
  2. » im new to javascript so please explain this code
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 04/17/2024 at 09:19:36