• 如何判断一个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="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 style="1px;height:2000px;"></div>
        <div id="eq" style=" 100px; height:100px; background-color:Red;">1</div>
        <div style="1px;height:2000px;"></div>
    </body>
    </html>
    

      

  • 相关阅读:
    内存对齐
    类和对象
    C++ 各种继承方式的类内存布局
    静态变量static
    程序内存布局
    String类
    C++与C的区别
    命名空间
    C
    D
  • 原文地址:https://www.cnblogs.com/kevinge/p/3937084.html
Copyright © 2020-2023  润新知