Skip to content Skip to sidebar Skip to footer

Jquery .toggle Replacement Code

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. I'm no g

Solution 1:

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");     
      }
  });
});

Post a Comment for "Jquery .toggle Replacement Code"