$(document).ready(function(){ var timer=null,indea=0; function carouselAvator(){ // 鼠标划过定时器 $('#avatar').mouseout(function(){ timer=setInterval(function(){ indea++; if (indea>1) { indea=0; } console.log(indea); changeImg(); },3000); }) // $('#avatar').mouseover(function(){ // clearInterval(time,) // }) $('#avatar').mouseout(); }function changeImg(){ if (indea=0) { $('#avatar .man').addClass('activer'); } else{ $('#avatar .man').removeClass('activer'); } }carouselAvator();})
1 回答
蓝冰记忆
TA贡献1条经验 获得超2个赞
原来那行这个:
if (indea = 0) {等号是不是用错了呢?
把它改成:
if (indea === 0) {再试试看!
附上修改了这行的程序:
$(document).ready(function () {
var timer = null,
indea = 0;
function carouselAvator() {
// 鼠标划过定时器
$('#avatar').mouseout(function () {
timer = setInterval(function () {
indea++;
if (indea > 1) {
indea = 0;
}
console.log(indea);
changeImg();
}, 3000);
})
// $('#avatar').mouseover(function(){
// clearInterval(time,)
// })
$('#avatar').mouseout();
}
function changeImg() {
if (indea === 0) {
$('#avatar .man').addClass('activer');
} else {
$('#avatar .man').removeClass('activer');
}
}
carouselAvator();
})添加回答
举报
0/150
提交
取消
