<script>
$(function () {
$('a[href*=#],area[href*=#]').click(function () {
console.log(this.pathname)
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
if ($target.length) {
var targetOffset = $target.offset().top;
$('html,body').animate({
scrollTop: targetOffset
},
1000);
return false;
}
}
});
})
</script>
直接将代码块粘贴进前端就行,1000是设置的移动速度,但是添加后可能会出现与折叠区域冲突的问题未解决。如下:
<a href="#page-stats" class="block-heading" data-toggle="collapse" style="font-family:SimSun;font-size:15px; margin-top: 0px;line-height:35px; height: 30px">得分趋势</a>
<div id ="page-stats" class="block-body collapse in" style="width:100%"></div>