Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Javascript create a div,which inside have img and p from array[i]

Tags: imgs

J.Yung:

I have this code:


var imglis = ['a.jpg', 'b.jpg', 'c.jpg'] //It is the images
var imgs = "";
var descs = ["a", "b", "c"]; //It is the description
var des = "";
var price = ["200", "300", "400"]; //It is the price
var p = "";

for (var i = 0; i var img = document.createElement('img');
var desc = document.createElement('p');
img.setAttribute('src', imglis[i]);
desc.innerHTML = descs[i];
imgs += img.outerHTML;
des += desc.outerHTML;
}

var image = document.getElementById('image');
image.innerHTML = imgs;
var descss = document.getElementById('descss');
descss.innerHTML = des;




It works, but the result isn't what I want.

I am looking for something like :


// This is the div created from first array,it should have 2 more




a


200




I stuck here for a century,please help me out.



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Javascript create a div,which inside have img and p from array[i]

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×