为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

李馆长jie 2018-02-20 15:54:14
$(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();
})


查看完整回答
2 反对 回复 2018-02-20
  • 1 回答
  • 0 关注
  • 1385 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信