使用jQuery判断Div是否在可视区域的方法 判断div是否可见
使用jQuery判断Div是否在可视区域的方法 判断div是否可见
发布时间:2016-12-30 来源:查字典编辑
摘要: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>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类