a标签

1、锚点跳转

①a标签跳转div

<a href='#aa'>点击跳转</a>

<div id='aa'>跳转到这里</div>

②a标签跳转a标签

<a href='#aa'>点击跳转</a>

<a name='aa'>跳转到这里</a>

2、点击回到页面顶部

<a href='#top'>点击回到页面顶部</a>

<a name='top'>跳转到的地方(顶部)

3、页面跳转问题

①href='#'

页面滚动到原始位置

加onclick='return false'可取消滚动到顶部

②href='###'

取消页面滚动到顶部,不做任何处理

2—4个#,##时IE6会识别为#,建议写3个

③href='javascript:void(0)'

同②,url地址不会受影响

4、JS实现

①页面滚动至顶部

$('.scroll_top').click(function(){$('html,body').animate({scrollTop: '0px'}, 800);}); 

②页面滚动至指定的位置

$('.scroll_a').click(function(){$('html,body').animate({scrollTop:$('.a').offset().top}, 800);});   

③ 页面滚动到底部

$('.scroll_bottom').click(function(){$('html,body').animate({scrollTop:$('.bottom').offset().top}, 800);}); 

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