我有这个代码在悬停时更改图像,有没有办法在div内部的mousemove上更改它 谢谢。
var images = ["images/warlo1.svg",
"images/warlo2.svg",
"images/warlo3.svg",
"images/warlo4.svg",
"images/warlo5.svg",
"images/warlo6.svg",
"images/warlo7.svg",
"images/warlo8.svg",],
i = 0,//counter
$swap = $(".swap"),//only get the object once
swapper;//setup a var for setInterval
function swapImg(){
i = Math.floor(Math.random() * images.length);//keep i under the array length
$swap.attr("src",images[i]);
i++;
}
$swap.hover(function(){//mouseover
swapper = setInterval(swapImg,300);//call function every 400
},function(){//mouseout
clearInterval(swapper);
});
答案 0 :(得分:0)
答案 1 :(得分:0)
function swapImg(){
if (toggle) {
// swap image here
toggle = false;
setTimeout(function() {
toggle = true;
}, 5000);
}
}