jack jack - 9 months ago 45
Javascript Question

How to create x amount of image box in html javascript?

So basically I've a simple project where users could upload some images. Now I need to create

boxes, where
contains the amount of photos that user have saved in my server.

I would really appreciate if somebody could tell me how to create x amount of image boxes in html.

Thanks in advance

Answer Source

Use jquery to create tags at runtime:


  var x = 10;
  for(var i=0; i<x; i++){
    $('body').append('<img src="http://cdn.mysitemyway.com/etc-mysitemyway/icons/legacy-previews/icons-256/firey-orange-jelly-icons-symbols-shapes/018349-firey-orange-jelly-icon-symbols-shapes-smiley-face1.png" alt="Smiley face" width="42" height="42">');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>