Javascript to loop / increment html code with values up to 55 -


i need create list of links in static (.html) page automatically, there way of doing using javascript. tired few scripts couldn't work out.

this html...

<a href="1.html"><img src="images/1.jpg" width="119" height="121" alt="" /></a> 

and want script generate 55 times...

<a href="1.html"><img src="images/1.jpg" width="119" height="121" alt="" /></a> <a href="2.html"><img src="images/2.jpg" width="119" height="121" alt="" /></a> <a href="3.html"><img src="images/3.jpg" width="119" height="121" alt="" /></a> 

... , on, call me lazy appreciated :)

this should trick:

<div id="links"> </div>  <script> var strlinks = '';  (var = 1; <= 55; i++) {     strlinks += '<a href="'+ +'.html"><img src="images/'+ +'.jpg" width="119" height="121" alt="" /></a>'; }  document.getelementbyid("links").innerhtml = strlinks; </script> 

js fiddle example: http://jsfiddle.net/rwudg/2/

edit: oops, missed quote. fixed.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -