How to use event.target.tagName? I haven't figured it out, it's still chaotic

If it is a div instead of an input, it will become a DIV

<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            #main {
    
    
                width: 200px;
                height: 100px;
                background: pink;
                color: #fff;
            }
        </style>
        <script type="text/javascript">
            window.onload = function() {
    
    
                document.getElementById("main").onclick = function(e) {
    
    
                    console.log(e.target);//<div id="main" class="sb js node"><span>测试文字</span></div>
                    console.log(e.target.id);//main
                    console.log(e.target.tagName);//DIV
                    console.log(e.target.nodeName);//DIV
                    console.log(e.target.classList);// ["sb", "js", "node", value: "sb js node"]
                    console.log(e.target.className);//sb js node
                    console.log(e.target.innerHTML);//<span>测试文字</span>
                    console.log(e.target.innerText);//测试文字
                }
            }
        </script>
    </head>

    <body>
        <div id="main" class="sb js node"><span>测试文字</span></div>
    </body>

</html>

Can't this display DIV either? What to do

vue3, there must be new vue
vue.
methods and the like

Guess you like

Origin blog.csdn.net/weixin_40945354/article/details/115243110