使用jQuery判断Div是否在可视区域的方法 判断div是

<!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="https://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>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="https://www.jb51.net/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>刷新测试</p> <div></div> </body> </html>

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgwyjy.html