简单的JS小功能

1.点击返回顶部(#top为返回顶部按钮)

$('#top').click(function () {

$('html , body').animate({scrollTop:$('html , body').offset().top},500);

});


2.点击返回同页面中某一位置(#con为页面中某一位置,滑动时间500)

$('#con').click(function () {

$('html , body').animate({scrollTop:$('.con').offset().top},500);

});


3.使用除a标签外的其他标签跳转页面

function accumulation_fund(){

window.location.href="accumulation_fund.html";

}

对应html

<li onclick=javascript:accumulation_fund()>

    <img src="../images/port1.jpg" alt="" style="width:100%;height:90%;margin-top:8%;">

    <p>*****</p>

</li>

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容