0

I have this code:

$('a[href*=#]').click(function() {

  $('html, body').animate({
    scrollTop: $($.attr(this, 'href')).offset().top
  }, 500);

  return false;
});

But I need a 600ms delay after click the link so my page have chance to perform other actions that I set to 500ms, thank you in advance

felipekm
  • 2,820
  • 5
  • 32
  • 42

2 Answers2

4

jQuery has a delay method

$('a[href*=#]').click(function(){
    $('html, body').delay(600).animate({
        scrollTop: $( $(this).attr('href') ).offset().top
    }, 500);

    return false;
});
adeneo
  • 312,895
  • 29
  • 395
  • 388
0

Check this out,

$('a[href*=#]').click(function(){
setTimeout(function()
{

// Things to do after 600ms

},600);

$('html, body').animate({
scrollTop: $( $.attr(this, 'href') ).offset().top
}, 500);
return false;
});
Nandan Bhat
  • 1,573
  • 2
  • 9
  • 21