<!DOCTYPE HTML>
<html>
<head>
<title>随手练习</title>
<meta charset="utf-8">
<style>
div { background:yellow;width:200px;height:300px;display:none;}
</style>
</head>
<body>
<input id="show" type="button" value="显示" />
<input id="hide" type="button" value="隐藏" />
<div id="div1"></div>
<script type="text/javascript">
window.onload = function (){
var show1 = document.getElementById("show");
var hide1 = document.getElementById("hide");
var div1 = document.getElementById("div");
show1.onclick = function (){
div1.style.display = "block";
div1.style.background = "red";
};
hide1.onclick = function (){
div1.style.display = "none";
};
};
</script>
</body>
</html>
田心枫
相关分类