我不确定这个链接是如何被称为something.com/#link我想动画这个浏览器动作。但是因为我不知道它们是如何调用的,所以无法找到正确的jquery插件或wiki。
泰,
答案 0 :(得分:0)
#link是一个哈希(或锚),通常是页面的id。浏览器会自动滚动到锚点,但如果要自定义此滚动,则如下所示:
if(location.hash) {
_hash = location.hash; // Stores hash
location.hash = ''; // Removes the native scroll of browser
var anchor = "#el_"+_hash;
var el = $(anchor); // Gets target element
$('html,body').animate({scrollTop: el.offset().top}, 'slow', function(){
location.hash = _hash; // Inserts the hash in url again
});
}