有哪位大神能看出问题?为什么indea的值一直都是1?

$(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();

})


李馆长jie
浏览 1390回答 1
1回答

蓝冰记忆

原来那行这个: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(); })
打开App,查看更多内容
随时随地看视频慕课网APP