Jquery .toggle replacement code

后端 未结 1 1706
误落风尘
误落风尘 2021-01-17 07:02

I have (had) a button on my website that switched between a wide and narrow layout for articles. Since JQuery 1.9, this hasn\'t worked because of the deprecation of toggle.

1条回答
  •  隐瞒了意图╮
    2021-01-17 07:23

    See my answer here

    which would translate to

    $(function() {                      
       $('a#switch').on("click",function(e) {
          e.preventDefault();
          if ($(this).data("show")=="no") {
                $('div#right').hide('slide', { direction: 'right' }, 300);
                $('div#left').delay(300).animate({width: 950}, 600);
                $('span#blogview').toggleClass('hide');
                $('span#articleview').toggleClass('hide');
                $('span#readability').toggleClass('hide');
            $(this).data("show","yes");
          }   
          else {
                $('div#right').delay(500).show('slide', { direction: 'right' }, 500);
                $('div#left').animate({width: 430}, 500);
                $('span#blogview').toggleClass('hide');
                $('span#articleview').toggleClass('hide');
                $('span#readability').toggleClass('hide');
            $(this).data("show","no");     
          }
      });
    });
    

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