1.寫css時候,屬性:屬性值,屬性值不加引號
2 寫js時候,屬性=屬性值,屬性值都要加引號
3 html元素有style屬性,可以直接在裏面設置屬性
4 html元素的事件也可以在行內直接添加,也可以指定函數,後面必須加括號,然後再sript段裏面定義該函數
5 html元素設置類時候用class屬性,但是在js中設置時候要用className
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
#dv{
width: 100px;
height: 100px;
background-color: grey;
}
.box{
width: 200px;
height: 200px;
background-color: red;
}
</style>
<script>
function togreen(){
var dv = document.getElementById('dv');
dv.style.height='200px';
dv.style.width='200px';
dv.style.backgroundColor='red';
}
function togrey(){
var dv = document.getElementById('dv');
dv.style.height='100px';
dv.style.width='100px';
dv.style.backgroundColor='grey';
}
</script>
</head>
<body>
<div id='dv' onmouseover="togreen()" onmouseout="togrey()">hello</div>
</body>
</html>