Twitter Typeahead - 如何使用 "afterSelect" 跳转到网站的另一部分?

Twitter Typeahead - How I can use "afterSelect" to jump to annother section of the website?

我尝试用"window.location.hash = '#section3';"选择后跳转,但这样不行..

$('#inputField').typeahead({
        source:  function (query, process) {
            return $.get('test.php', { query: query }, function (data) {
                console.log(data);
                data = $.parseJSON(data);
                return process(data);
            });
        },
        afterSelect: function (item) {
            window.location.hash = '#section3';
        }
    });

感谢您的帮助!

将 window.location 更改为 scrollTop

脚本

$('#inputField').typeahead({
    source:  function (query, process) {
        return $.get('test.php', { query: query }, function (data) {
            console.log(data);
            data = $.parseJSON(data);
            return process(data);
        });
    },
    afterSelect: function (item) {
        //window.location.hash = '#section3';
        $("html, body").animate({ scrollTop: $('#section3').offset().top }, 1000);
    }
});