Trying to display random javascript images in separate DIVs

I have working javascript code that produces multiple random images in to one DIV.
I have tried a few attempts to display each random image in a separate DIV but with no luck. I got "close" but no success.
Here is working code:

<style>.onetwothreefour {  width: 25%;  display: inline-block;}</style>
function displayNow() {
var images = ["00.png","01.png","02.png","03.png","04.png","05.png","06.png"];
var selectedIndices = []
while (selectedIndices.length < 4) {
var index = images[Math.floor(Math.random() * images.length)]
if (selectedIndices.indexOf(index) == -1) {
 for (i = 0; i < selectedIndices.length; i++) {
 var img = document.createElement("img");
 img.src = "imagesfolder/" + selectedIndices[i]
 img.className = "onetwothreefour"
 var src = document.getElementById("images");
<body onLoad="displayNow();">
<div id="images"><!-- Images --></div>

<!-- the above works fine but I would like the result below -->

<div class="container"><div class="row">    
<div id="" class=""><img src="" id="" class=""></div>
<div id="" class=""><img src="" id="" class=""></div>
<div id="" class=""><img src="" id="" class=""></div>
<div id="" class=""><img src="" id="" class=""></div>

Note: I have jquery and bootstrap loaded.
I appreciate any help.

81 thoughts on “Trying to display random javascript images in separate DIVs”

  1. This design is steller! You certainly know how to keep a
    reader entertained. Between your wit and your videos, I was almost moved to
    start my own blog (well, almost…HaHa!) Wonderful job.
    I really loved what you had to say, and more than that, how you presented it.
    Too cool!

  2. Hi this is somewhat of off topic but I was wondering if blogs use WYSIWYG editors or if
    you have to manually code with HTML. I’m starting a blog soon but have
    no coding experience so I wanted to get advice from someone with experience.
    Any help would be greatly appreciated!

  3. You actually make it appear so easy together with your presentation but I find this topic to be really something which I believe I’d by no means understand.
    It kind of feels too complex and very extensive for me.
    I’m looking forward in your subsequent submit, I will attempt to get the dangle of it!

  4. Good day! This post couldn’t be written any better! Reading this post reminds
    me of my old room mate! He always kept talking about this.
    I will forward this page to him. Pretty sure he will have a good read.

    Thanks for sharing!

  5. Excellent pieces. Keep posting such kind of info on your blog.
    Im really impressed by it.
    Hey there, You have performed a fantastic job.
    I will definitely digg it and for my part suggest to my friends.

    I am confident they’ll be benefited from this site.

  6. An interesting discussion is worth comment. There’s no doubt that
    that you need to write more about this subject matter, it might not be a taboo
    subject but generally folks don’t talk about such topics.
    To the next! Many thanks!!


Leave a Comment