• JS判断全屏,Jquery绑定动态元素Parent元素单击事件


    <!DOCTYPE HTML>
    <html>
    
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    
    <body>
        <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
        <script>
            //兼容IE
            function isFullscreen() {
                return document.fullscreenElement ||
                    document.msFullscreenElement ||
                    document.mozFullScreenElement ||
                    document.webkitFullscreenElement || false;
            }
            setInterval(function () { if (isFullscreen()) { console.log('Fullscreen') } else { console.log('Not Fullscreen') } }, 2000);
    
            //绑定动态元素Parent元素单击事件
            setInterval(function () {
                if ($('.on-parent')) {
                    $('.on-parent').parent().off('click').click(function () {
                        alert('循环器绑定动态元素Parent元素单击事件');
                    })
                }
            }, 100)
            //各浏览器全屏改变事件,IE部分不兼容
            document.addEventListener("fullscreenchange", function () {
                console.log((document.fullscreen) ? "全屏" : "非全屏");
            }, false);
    
            document.addEventListener("mozfullscreenchange", function () {
                console.log((document.fullscreen) ? "全屏" : "非全屏");
            }, false);
    
            document.addEventListener("webkitfullscreenchange", function () {
                console.log((document.fullscreen) ? "全屏" : "非全屏");
            }, false);
    
            document.addEventListener("msfullscreenchange", function () {
                console.log((document.fullscreen) ? "全屏" : "非全屏");
            }, false);
    
            function appentonParent() {
                $('#btnAppentonParent').after('<div><p>OnParent</p><p class="on-parent">On</p></div>');
            }
            //绑定动态元素Parent元素单击事件 无效
            $(document).on('click', '.on-parent:parents', function () {
                alert('绑定动态元素Parent元素单击事件');
            })
        </script>
        <video src="http://vfx.mtime.cn/Video/2019/02/04/mp4/190204084208765161.mp4" controls="controls">
            浏览器不支持Video
        </video>
        <br />
        <button id="btnAppentonParent" onclick="appentonParent()">
            追加动态元素
        </button>
    </body>
    
    </html>
  • 相关阅读:
    hdu 1863 畅通工程
    pku 1275 Cashier Employment
    hdu 1879 继续畅通工程
    hdu 1301 Jungle Roads
    zoj1655 Transport Goods
    人生最大的遗憾,莫过于错误的坚持,和轻易的放弃……
    职业发展
    win8学习手册
    铭记这些题
    android 定制PreferenceScreen
  • 原文地址:https://www.cnblogs.com/ChenRihe/p/11818358.html
Copyright © 2020-2023  润新知