fadeToggle() not working

后端 未结 5 1357
忘了有多久
忘了有多久 2021-01-28 14:20

I has a strange error when using fadeToggle()

the jquery library inside the head section is: jquery-1.4.2.min.js

and this is the simple function:

5条回答
  •  生来不讨喜
    2021-01-28 14:38

    fadeToggle was added in 1.4.4 http://api.jquery.com/fadeToggle/

    so, that would be why, try updating your jQuery version to the latest and it should be good to go!

    ps: make sure you read up on breaking changes before you upgrade, b/c there's been some pretty big changes from the early 1.4 ->1.5+

    You can fake FadeToggle using animate:

    $('#Div1').click(function(){
    
        if($('#Div2').css('opacity') == 1){
    
            $('#Div2').animate({opacity:0}, 1000);
        }
        else{
            $('#Div2').animate({opacity:1}, 1000);
        }
    
    });
    

    have a look at my fiddle: http://jsfiddle.net/B73Sj/3/

提交回复
热议问题