手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >使用jQuery判断Div是否在可视区域的方法 判断div是否可见
使用jQuery判断Div是否在可视区域的方法 判断div是否可见
摘要:js$(document).ready(function(){$(window).scroll(function(){vara=docume...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>js</title> <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $(window).scroll(function () { var a = document.getElementById("eq").offsetTop; if (a >= $(window).scrollTop() && a < ($(window).scrollTop()+$(window).height())) { alert("div在可视范围"); } }); }); </script> </head> <body> <div></div> <div id="eq">1</div> <div></div> </body> </html>

以上代码是小编给大家介绍的使用jQuery判断Div是否在可视区域的方法,希望对大家有所帮助。接下来一段代码给大家介绍jquery如何判断div是否隐藏,具体代码如下所示:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> jquery 如何判断div是否隐藏| jquery判断div是否隐藏 <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.3.2.js"></script> <script> $(document).ready(function(){ var temp= $("#test").is(":hidden");//是否隐藏 var temp1= $("#test").is(":visible");//是否可见 alert(temp) ; alert(temp1) ; }); </script> </head> <body> <p onclick='test()'>刷新测试</p> <div id="test"></div> </body> </html>

【使用jQuery判断Div是否在可视区域的方法 判断div是否可见】相关文章:

jQuery实现首页图片淡入淡出效果的方法

JQuery+CSS实现图片上放置按钮的方法

js判断鼠标位置是否在某个div中的方法

jQuery获得字体颜色16位码的方法

JQuery自动触发事件的方法

jQuery实现转动随机数抽奖效果的方法

jquery实现的判断倒计时是否结束代码

基于jquery实现下拉框美化特效

jQuery判断一个元素是否可见的方法

jQuery实现延迟跳转的方法

精品推荐
分类导航