jQuery toggle animation doesn't work on new jQuery

后端 未结 1 662
-上瘾入骨i
-上瘾入骨i 2020-12-12 07:50

I have problem with this toggle on jQuery 1.8.2 i works but on 1.11.0 no. Can you help me what is wrong?

$(\'.open\').toggle(function () {
    $(\'.obj\').an         


        
1条回答
  •  一整个雨季
    2020-12-12 08:25

    As mentioned in the comments you will need to do this using the click method. Here is an example that uses the element's data to store the state:

    $('.open').on('click', function(){
        var isToggled = $(this).data('isToggled');
        if(isToggled){
            $('.obj').animate({
                top: "-8%",
            }, 500);
        } else {
          $('.obj').animate({
                top: "0"
            }, 500);
        } 
    
        $(this).data('isToggled', !isToggled)
    });
    

    0 讨论(0)
提交回复
热议问题