开发者

fadeToggle() not working

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:

 $(function(){
         $("#div1").click(function () {
                $("#div2").fadeToggle();
            });

            $("#div3").click(function () {
                $("#div4").fade开发者_高级运维Toggle();
            });
        });

  </script>

and this is the error from firebug

$("#div2").fadeToggle is not a function

I tried to change the jquery library to- jquery.js but then all the jquery plugin stop working and the error is the same

Any Idea what causing this

Thanks

Baaroz


fadeToggle function is only available in jQuery 1.4.4 and above.

:)


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/


fadeToggle() "version added: 1.4.4".


fadeToggle was added on version 1.4.4 -- you won't be able to use it without updating your jQuery.


http://api.jquery.com/fadeToggle/

version added: 1.4.4

Update to the latest version, and try again :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜