I have few divs .posts which have a attr data-id which corresponds to the mysql DB id.
div
.posts
data-id
mysql DB id
You can use jQuery.ScrollTo plugin: https://github.com/flesler/jquery.scrollTo
In this link you can find demos http://demos.flesler.com/jquery/scrollTo/
$(function() { $('body').scrollTo($('div[data-id=1]'), 1000); //scroll to div 1 });
HTML: