(003)dom_dom0级事件处理程序

dom0级事件处理程序

较传统的方式,把一个函数赋值给一个事件的处理程序属性

用得比较多的方法 简单 跨浏览器优势

<html>
    <head>
    </head>
    <body>
        <div id="box">
            <input type="button" value="button" id="btn" onclick="showMsg()">
            <input type="button" value="dom0 button" id="btn2">
        </div>
        <script type="text/javascript">
            function showMsg() {
                alert("hello");
            }
            var btn2 = document.getElementById("btn2");
            btn2.onclick = function() {
                alert("this is dom0 click event");
            };
        </script>
    </body>
</html>

 

posted @ 2015-02-08 11:31  雪中飞雁  阅读(82)  评论(0)    收藏  举报