抽奖系统怎么设置图片?
var oTitle = document.getElementById('title'),
oPlay = document.getElementById('play'),
oStop = document.getElementById('stop'),
oSSR = document.getElementById('ssr');
var timer = null;
var nSSR = ['大天狗', '茨木童子', '萊因哈特', '逃兵76'];
//主體函數
window.onload = function () {
var oPlay = document.getElementById('play'),
oStop = document.getElementById('stop');
oPlay.onclick = playFn;
oStop.onclick = stopFn;
}
function playFn() {
clearInterval(timer);
var oTitle = document.getElementById('title');
timer = setInterval(function () {
var random = Math.floor(Math.random() * nSSR.length);
oTitle.innerHTML = nSSR[random];
}, 50);
}
function stopFn() {
clearInterval(timer);
}
这是我写的代码 我设置了一个盒子想让里面显示的图片也跟着变化 我用了document.getElementById('img').src=""不行 用了img.setAttribute(src,url)也不行 请问怎么做