$('a[href^="#"]').on('click', function(e) {

    var positionTop;
    var $this = $(this);

    var target = $($this.attr('href'));

    if( target.length ) {

        e.preventDefault();


        $('body, html').animate({ // html needs to be there for Firefox
            scrollTop: target.position().top
        }, 1000);
    }
});
