通过Javascript的多个图像?
我对这一点比较陌生,目前有两个例子:通过Javascript的多个图像?,javascript,jquery,html,Javascript,Jquery,Html,我对这一点比较陌生,目前有两个例子: var img = new Image(); var div = document.getElementById('Latest_A'); img.onload = function() { Latest_A.appendChild(img); }; img.src = '../Latest_A.jpg'; 然后是另一个,B等等 目前它只调用最后一个实例?是否同时调用这两个或多个图像?我很确定您正在尝试从图像URL列表向同一元素添加多个图像
var img = new Image();
var div = document.getElementById('Latest_A');
img.onload = function() {
Latest_A.appendChild(img);
};
img.src = '../Latest_A.jpg';
然后是另一个,B等等
目前它只调用最后一个实例?是否同时调用这两个或多个图像?我很确定您正在尝试从图像URL列表向同一元素添加多个图像 这将从数组中获取URL列表,并将每个URL添加到选定的div。它还将为每个URL分配一个唯一的id,以防您需要为每个URL设置样式 var div=document.getElementById'Latest_A'; var imageArray=['http://placehold.it/200x200','http://placehold.it/200x300','http://placehold.it/300x200','http://placehold.it/200x150']; 对于var i=0;i