I’ve the following function:
$('.link1').click(function(){
$("#div2").slideUp(function(){$("#div1").slideToggle();});
$('html, body').animate({scrollTop: '600px'}, 800);
});
It toggles a div and scroll the page down. The problem is that everytime the user toggles the page scroll down again…how could I run this animate function only at first click?
Use a flag or set a data attribute to make sure the scrolling animation only occurs on the first click.
I’m guessing
#div2should still toggle, but that it just should’nt scroll on every click?