使用js实现html锚功能,可以任意定位锚的位置,比锚更加灵活 jquery两行代码即可实现: var pos = $("#" + targetele).offset().top; $("html,body").animate({ scrollTop: pos }, 1000);