scrollTop jQuery, scrolling to div with id? scrollTop jQuery, scrolling to div with id? javascript javascript

scrollTop jQuery, scrolling to div with id?


instead of

$('html, body').animate({scrollTop:xxx}, 'slow');

use

$('html, body').animate({scrollTop:$('#div_id').position().top}, 'slow');

this will return the absolute top position of whatever element you select as #div_id


My solution was the following:

document.getElementById("agent_details").scrollIntoView();


try this:

$('html, body').animate({scrollTop:$('#xxx').position().top}, 'slow');$('#xxx').focus();