123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- #box1 {
- width: 400px;
- height: 400px;
- background: #00f;
- }
- #box2 {
- width: 200px;
- height: 200px;
- background: #ff0;
- }
- </style>
- </head>
- <body>
- <div id="box1">
- <div id="box2"></div>
- </div>
- <script>
- const box1 = document.getElementById("box1");
- const box2 = document.getElementById("box2");
- box1.addEventListener('click', function () {
- console.log("大盒子")
- },false)
- box2.addEventListener('click', function () {
- console.log("小盒子")
- },false)
- </script>
- </body>
- </html>
|