<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>diyici</title>
<style>
#div1{
width:100px;
height:100px;
background:red;/*只能是~ color沒用*/
border:1px solid;
display:block;/*作用:隱藏信息框*/
}
</style>
<script>
function ToGreen(){/*駝峯命名法*/
document.getElementById('div1').style.height='200px';
document.getElementById('div1').style.width='200px';
document.getElementById('div1').style.background='green';
document.getElementById('div1').style.display='block';/*這裏的div1和200px green什麼的必須是單引號
且後面這幾個必須由引號括起來 因爲最外圍是雙引號*/
}
function ToRed(){
document.getElementById('div1').style.display='none';
//鼠標離開搜索框 框恢復原樣 (隱藏)
}
</script>
</head>
<body>
<input type="checkbox" onmouseover="ToGreen()" onmouseout="ToRed()" />
<div id="div1">
爲了您的信息安全;
</div>
<p>注意分清style和type</p>
<p>注意把哪些部分拿去當了函數(沒有onmouseover的事)</p>
</body>
</html>
實例
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.