event.target.tagNameの使用方法は?私はそれを理解していません、それはまだ混沌としている

入力ではなくdivの場合、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>

これもDIVを表示できませんか?何をすべきか

vue3、新しいVUEのがなければならない
VUE。
方法など

おすすめ

転載: blog.csdn.net/weixin_40945354/article/details/115243110