小编给大家分享一下使用

随着网站页面的出现,使用滚动作为导航长页面的方法变得越来越流行。使用JS + jQuery代码,可以轻松地在nav元素中设置链接以滚动到页面的相应部分。如果你希望在JS不存在时很好地降级,请将锚标记添加到页面中,本篇文章就来给大家介绍关于使用
下面是具体的代码
Coffeescript:
$("nav").find("a").click (e) ->
e.preventDefault()
section = $(this).attr "href"
$("html, body").animate
scrollTop: $(section).offset().top或JS代码:
$("nav").find("a").click(function(e) {
e.preventDefault();
var section = $(this).attr("href");
$("html, body").animate({
scrollTop: $(section).offset().top
});
});HTML代码:
Welcome to this websiteAbout this website, and suchThe third section
看完了这篇文章,相信你对使用

售后响应及时
7×24小时客服热线
数据备份
更安全、更高效、更稳定
价格公道精准
项目经理精准报价不弄虚作假
合作无风险
重合同讲信誉,无效全额退款