123456789101112131415161718192021222324252627282930 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <div id="box">
- <span>a</span>
- <span>b</span>
- <span>c</span>
- </div>
- <script>
- // var aSpan = document.getElementsByTagName("span");
- // for(var i=0;i<aSpan.length;i++){
- // aSpan[i].onclick = function(){
- // console.log(this.innerText);
- // }
- // }
- var oBox = document.getElementById("box");
- oBox.onclick = function(e){
- // console.log(this.innerText)
- console.log(e.target.innerText)
- }
- </script>
- </body>
- </html>
|