<script src="http://libs.baidu.com/jquery/1.7.0/jquery.min.js"></script> <style> .aa{ display:none; width:750px; height:100px; background:#5e39db; position:fixed; bottom:1000px; } </style> <script> $(function(){ var highly = 3000;//滚动到3000像素时显示 var m_highly = 3000;//滚动到3000像素时隐藏 $(window).scroll( function () { highly = Math.max(document.body.scrollTop || document.documentElement.scrollTop);//获取垂直滚动的偏移值 // "||"这两种是为了消除标准模式和怪异模式之间的差别而做的兼容 if (highly > m_highly) { $('.aa').slideDown();//className : aa 以滑动方式显示被选元素当大于3000时显示 }else{ $('.aa').slideUp();//className : aa 以滑动方式隐藏被选元素当小于3000时隐藏 } }) }); </script>
<body> <div style="width:100%;height:5000px;background:#EEE;"></div> <div class="aa" >div的className为aa。滚动高度3000显示</div> </body>