【发布时间】:2015-06-17 15:43:41
【问题描述】:
我的自制图像滑块有问题,我收到错误:Uncaught TypeError: Cannot set property 'src' of null
编辑:我已将所有图像称为:img1、img2、img3 等,扩展名为 .jpg
这是我的 javascript 代码:
// JavaScript Document
var imagecount = 1;
var total = 3;
window.setInterval(function slideA(x)
{
var Image = document.getElementById('img');
imagecount = imagecount + x;
if(imagecount > total) { imagecount = 1; }
if(imagecount < 1) { imagecount = total; }
Image.src = "images_slider/img" + imagecount + ".jpeg";
}, 5000);
function init()
{
slideA();
}
window.onload = init;
<div id="LandingImage">
<img src="../images/landingimage.png" alt="LandingImage" width="100%" height="100%" />
</div>
有人可以帮我解决这个问题吗? 谢谢!
凯文。
【问题讨论】:
标签: javascript html slider