首页 > 代码库 > jQuery滑动到锚点

jQuery滑动到锚点

<map name="Map">
<area shape="rect" coords="6,13,149,78" href="http://www.mamicode.com/#bottom">
<area shape="rect" coords="5,117,144,148" href="http://www.mamicode.com/#t1">
<area shape="rect" coords="3,149,146,180" href="http://www.mamicode.com/#t3">
<area shape="rect" coords="4,181,145,212" href="http://www.mamicode.com/#t2">
<area shape="rect" coords="4,212,141,244" href="http://www.mamicode.com/#t4">
<area shape="rect" coords="3,242,144,273" href="http://www.mamicode.com/#t5">
<area shape="rect" coords="3,272,142,309" href="http://www.mamicode.com/#t6">
<area shape="rect" coords="4,308,144,345" href="http://www.mamicode.com/#t7">
<area shape="rect" coords="5,347,149,404" href="http://www.mamicode.com/#t8">
<area shape="rect" coords="6,84,142,117" href="http://www.mamicode.com/#bottom">
</map>

jQuery(function($) {    

    $("map[name=‘Map‘] area").click(function() {    
        $("html, body").animate({    
            scrollTop: $($(this).attr("href")).offset().top
        }, 1500);    
        return false;    
    });    
});

jQuery滑动到锚点