jquery实现页面滑动到固定位置显示某个divhttp://blog.csdn.net/doudou_demo/article/details/47829249

来源:互联网 发布:两个字符串相似度算法 编辑:程序博客网 时间:2024/06/05 18:44
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script src="jquery-1.11.1.min.js" type="text/javascript"></script><script type="text/javascript">$(window).scroll(function(){    var h=$(this).scrollTop();//获得滚动条距top的高度    //alert(h);     if(h>100){        $("#xianshi").fadeIn();    }else{        $("#xianshi").fadeOut();    }});</script><style type="text/css">#test{    width:300px;    height:700px;    margin-top:100px;    background-color:#09C;}#xianshi{    width:100px;    height:100px;    position:fixed;    bottom:200px;    left:600px;    background-color:#36C;    display:none;}</style></head><body><div id="test"></div><div id="xianshi"></div></body></html>


阅读全文
0 0