Toggle stopped working after jquery update

后端 未结 2 481
独厮守ぢ
独厮守ぢ 2021-01-16 12:11

I was using jquery 1.3 on my website. Today I updated it to newest 1.9 and my toggle/animate script stopped to work.

The code looks like that:



        
相关标签:
2条回答
  • 2021-01-16 13:00
    $('#toggler').click( function() {
        $('#tcontent').toggle(
            function()
            {
                $(this).animate({height: "70"}, 800);
            },
            function()
            {
                $(this).animate({height: "6"}, 800);
            }
        );
    });
    
    0 讨论(0)
  • 2021-01-16 13:13

    Try this

    <a href="#" id="toggler" data-show="no">Show more</a>
    

    and

    $(function() {                      
      $('#toggler').on("click",function(e) {
          if ($(this).data("show")=="no") {
            $('#tcontent').animate({height: "70"}, 800);
            $(this).data("show","yes");
          }   
          else {
            $('#tcontent').animate({height: "6"}, 800);
            $(this).data("show","no");     
          }
      });
    });
    
    0 讨论(0)
提交回复
热议问题