|
@@ -0,0 +1,25 @@
|
|
|
+<!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>
|
|
|
+ <!-- 在html标签上 style属性内写的样式 称之为內联样式 -->
|
|
|
+ <div style="font-size: 50px;font-weight: bolder;" class="box">hello world</div>
|
|
|
+ <button id="btn">按钮</button>
|
|
|
+ <script>
|
|
|
+ var oBox = document.getElementsByClassName("box")[0];
|
|
|
+ var oBtn = document.getElementById("btn");
|
|
|
+
|
|
|
+ oBtn.onclick = function(){
|
|
|
+ oBox.style.color = "red";
|
|
|
+ // js控制样式的时候如果出现中横线连接符 换成驼峰命名
|
|
|
+ var testNum = 100;
|
|
|
+ oBox.style.marginLeft = testNum + "px";
|
|
|
+ }
|
|
|
+
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|