各位帮忙看一下,我点击显示按钮,不显示我设置的DIV样式,代码我测了下没有问题啊 ,为什么就是不出来效果
<!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>
我們
慕标2337738
慕标2337738
相关分类