0
   

creating links with loops and Arrays

 
 
Loll3ro
 
Reply Fri 2 Jan, 2015 05:27 am
Hello, my question how do i make my code which creates one link with arrays into a loop which would create links from all of the arrays values?

<html>
<head>
</head>
<body>
<script>

var links = ["http://example.com","http://example.com","http://example.com","http://example.com"];
var titles = ["link1","link2","link3","link4"];
var a = document.createElement('a');
var linkText = document.createTextNode(titles[0]);
a.appendChild(linkText);
a.title = titles[0];
a.href = links[0];
document.body.appendChild(a);

</script>
</body>
</html>
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 531 • Replies: 0
No top replies

 
 

Related Topics

 
  1. Forums
  2. » creating links with loops and Arrays
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 04/24/2024 at 12:26:41