javascript - Add images to a table one by one -
can please advise how can load images array (called preloadarray) table cells 1 one. table 13 x 4 cells. function meant increment image id , call add them short settimeout() delay process & make animated. appreciated. thanks.
function showcard(){ //when button clicked document.writeln("<table>"); (m = 0; m < 4; m++) { document.writeln("<tr>"); (n = 0; n < 13; n++) { preloadimages[n] = new image(); preloadimages[n].src = n + '.gif'; document.writeln("<td id=\"\"><img height=\"80\" id=\"" + preloadimages[(m * 13) + n] + "\" \"></td>"); } document.writeln("</tr>"); } document.writeln("</table>"); }
you don't need preload images in array if directly specifying src..
here code you
<!doctype html> <html> <head> <title></title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <script> function showcard() { var t = "<table><thead></thead><tbody>"; (m = 0; m < 4; m++) { t += "<tr>"; (n = 0; n < 4; n++) { t += "<td><img height=\"80\" width=\"80\" src=\"" + ((m * 4) + n) + ".jpg\"/></td>"; } t += "</tr>"; } t += "</tbody></table>"; document.getelementbyid("ll").innerhtml = t; } </script> </head> <body onload="showcard();"> <div id="ll"></div> </body> </html>
Comments
Post a Comment