您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

基于jquery的返回顶部效果(兼容IE6)_jquery

2025/11/25 14:38:36发布12次查看
最近也在学jquery,就顺便记录一下了。
html
复制代码 代码如下:
css
复制代码 代码如下:
.scroll{
background:url(../image/scroll.gif) no-repeat center top transparent;
bottom:100px;
cursor:pointer;
height:67px;
width:18px;
position:fixed;
_position:absolute; /*兼容ie6*/
_top: expression(eval(document.documentelement.scrolltop)+700); /*700为图片距离顶部的设定距离,可以修改。不加700则图片紧贴在顶部滚动*/
}
html{_text-overflow:ellipsis;} /*解决ie6下图片抖动*/
top.js
复制代码 代码如下:
$(document).ready(function(){
var show_delay;
var scroll_left=parseint((document.body.offsetwidth-960)/2)+961; //960为页面宽度
$(.scroll).click(function (){
document.documentelement.scrolltop=0;
document.body.scrolltop=0;
});
$(window).resize(function (){
scroll_left=parseint((document.body.offsetwidth-960)/2)+961;
$(.scroll).css(left,scroll_left);
});
reshow(scroll_left,show_delay);
});
function reshow(marign_l,show_d) {
$(.scroll).css(left,marign_l);
if((document.documentelement.scrolltop+document.body.scrolltop)!=0)
{
$(.scroll).css(display,block);
}
else
{
$(.scroll).css(display,none);}
if(show_d) window.cleartimeout(show_d);
show_d=settimeout(reshow(),500);
}
最后不要忘记了jquery.js文件哦!
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product