用js改变backgroundImage属性,在iphone上测试,每次更换图片都会闪一下。update:只有iphone会闪,使用了onload也闪,代码如下 function selection(num0, num1, num2) { var img = new Image(); img.src = urls[num0][1]; img.onload = function () { console.log("complete"); selections[num0].style.backgroundImage = "url(" + urls[num0][1] + ")"; list[num0].style.display = "block"; selections[num1].style.backgroundImage = "url(" + urls[num1][0] + ")"; list[num1].style.display = "none"; selections[num2].style.backgroundImage = "url(" + urls[num2][0] + ")"; list[num2].style.display = "none"; } }
添加回答
举报
0/150
提交
取消