我试图在显示图片时更改图片的不透明度,但不确定如何在我的函数中使用它。
该代码运行正常,但是当我包含setAttribute
时无济于事
for (j = 4; j > 0; j--) {
if (keyPicture1 == reel01.length) {
keyPicture1 = 0;
}
pictureInUse = reel01[keyPicture1];
setTimeout((function(){
this.el.src = this.pic;
}).bind({el:document.getElementById("reel1-anima" + j).setAttribute("style","opacity:0.5", pic: 'images/image' +
pictureInUse + '.jpg', i: i, spinTimes: spinTimes, pictureInUse: pictureInUse, keyPicture1: keyPicture1}), duration);
duration += interval;
keyPicture1 += 1;
}
答案 0 :(得分:0)
将其更改为.prop()
.bind({el:document.getElementById("reel1-anima" + j).prop("style","opacity:0.5", pic: 'images/image' +
pictureInUse + '.jpg', i: i, spinTimes: spinTimes, pictureInUse: pictureInUse, keyPicture1: keyPicture1}), duration);
duration += interval;