zoukankan      html  css  js  c++  java
  • javascipt事件绑定

    <html>
    <head>
    <script type="text/javascript">
        function test(){
    
            window.alert("你投了一票");
            //解除绑定 IE 独有
            //document.getElementById("tp").detachEvent("onclick",test);
            //W3C 标准
            document.getElementById("tp").removeEventListener("click",test);
        }
        
    </script>
    </head>
    <body>
    <input type="button" id="tp" value="投票" />
    </body>
    <script>
        //绑定事件监听 IE独有
        //document.getElementById("tp").attachEvent("onclick",test);
        ////W3C 标准
        document.getElementById("tp").addEventListener("click",test);
    </script>
    </html>
  • 相关阅读:
    UVa10779
    UVa10779
    C++ 内存管理学习笔记
    c++ 学习笔记
    AcWing 275 传纸条
    I
    Tree HDU6228
    Lpl and Energy-saving Lamps
    C
    Secret Poems
  • 原文地址:https://www.cnblogs.com/pwm5712/p/3024235.html
Copyright © 2011-2022 走看看