码迷,mamicode.com
首页 > 编程语言 > 详细

JavaScript事件属性event.target

时间:2016-10-08 01:56:07      阅读:1230      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            #main {
                width: 200px;
                height: 100px;
                background: red;
            }
        </style>
        <script type="text/javascript">
            window.onload = function() {
                document.getElementById("main").onclick = function(e) {
                    console.log(e.target);
                    console.log(e.target.id);
                    console.log(e.target.tagName);
                    console.log(e.target.nodeName);
                    console.log(e.target.classList);
                    console.log(e.target.className);
                    console.log(e.target.innerHTML);
                    console.log(e.target.innerText);
                }
            }
        </script>
    </head>

    <body>
        <div id="main" class="sb js node"><span>我爱JavaScript</span></div>
    </body>

</html>

 

JavaScript事件属性event.target

标签:

原文地址:http://www.cnblogs.com/libin-1/p/5936997.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!