|
@@ -0,0 +1,32 @@
|
|
|
|
+<!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>
|
|
|
|
+ .box{
|
|
|
|
+ width: 100px;
|
|
|
|
+ height: 100px;
|
|
|
|
+ background-color: red;
|
|
|
|
+ }
|
|
|
|
+ </style>
|
|
|
|
+</head>
|
|
|
|
+<body>
|
|
|
|
+ <div class="box"></div>
|
|
|
|
+ <script>
|
|
|
|
+ var oBox = document.getElementsByClassName("box")[0];
|
|
|
|
+ oBox.onclick = function(){
|
|
|
|
+ oBox.style.width = "200px";
|
|
|
|
+ // 如果出现 background-color 修改成backgroundColor 驼峰命名方式
|
|
|
|
+ oBox.style.backgroundColor="blue";
|
|
|
|
+ this.style.height = "400px";
|
|
|
|
+ }
|
|
|
|
+ var oHtml = document.documentElement;
|
|
|
|
+ console.log(oHtml)
|
|
|
|
+ oHtml.onclick = function(){
|
|
|
|
+ console.log("click")
|
|
|
|
+ }
|
|
|
|
+ </script>
|
|
|
|
+</body>
|
|
|
|
+</html>
|