代码如下,按照视频里老师的例子写的。他的可以运行,我这怎么就运行不了呢?求解答,谢谢!<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>显示隐藏</title>
<style>
#div1{
width: 100px;
height: 400px;
background-color: #ccc;
display: none;
}
</style>
</head>
<body>
<input type="button" value="Button" onclick="showHide()">
<div id="div1"></div>
<script>
function showHide() {
var oDiv = document.getElementById('div1')
if (oDiv.display == 'block'){
oDiv.display = 'none'
}
else{
oDiv.display = 'block';
}
}
</script>
</body>
</html>
添加回答
举报
0/150
提交
取消