Thursday, 13 March 2014

Jquery scroll to element with id equals hash on page load



$(document).ready( function () {
    //check if hash is not empty
    if (window.location.hash) {
        var type = window.location.hash.substr( 1);
        //scroll to div with id '#result_' +type
        $ ("html,body" ).animate ({
            scrollTop : $('#result_' + type).offset().top
        }, 300);
    }
});

No comments:

Post a Comment