[作特效, 學JS] -- 02 鼠標移入, div變大變紅, 鼠標移出, 恢復原貌

效果是醬嬸兒的...

原始代碼

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style> #div1{ width: 200px; height: 200px; background-color: grey; position: absolute; z-index: 20; } #div2{ width: 300px; height: 300px; background-color: red; position: absolute; display:none; } </style>
</head>
<body>
	<div id="div1" onmouseover="overSmall()" ></div>
	<div id="div2" onmouseout="outBig()"></div>
</body>
<script> var small = document.getElementById('div1'); var big = document.getElementById('div2'); function overSmall() { small.style.display = "none"; big.style.display = "block"; } function outBig() { big.style.display = "none"; small.style.display = "block"; } </script>
</html>
複製代碼

專欄地圖

相關文章
相關標籤/搜索