jack jack - 1 year ago 78
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>


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download