I am having a problem with jquery animate scrollTop for a specific div.
I use this code to animate scroll:
$('body').animate({scrollTop: $('#sections_display').offset().top-100}, 500, function(){ $('#ajax_load').load('file.php'); });
But this does not work in Firefox or in IE.
And when I use $('html').animate instead of $('body').animate , it does not work in Chrome.
I also tried using both: $('html,body').animate , but the problem is that the callback function is $('#ajax_load').load('file.php'); executed twice, and this call invokes the file 2 times.
I temporarily solved the problem using php , but this solution made me repeat the code 2 times on each page to create 2 arrays of browsers that support $('body').animate and $('html').animate .
I searched here and found this: jquery animate scrolltop callback But it didn't work.
I also tried:
$(window).animate
$(document).animate
$('#container-div').animate
But not for that.
Can I find a cross browser method to achieve this?
source share