为什么我的不能隐藏内容
大佬们帮我看一下
大佬们帮我看一下
2018-07-05
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>style样式</title>
</head>
<body>
<h2 id="con" onclick="cc()">I love JavaScript</H2>
<p> JavaScript使网页显示动态效果并实现与用户交互功能。</p>
<script type="text/javascript">
var clr=document.getElementById("con");
clr.style.color="red";
clr.style.backgroundColor="#ccc";
function cc(){
clr.style.display="none"
}
</script>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html;">
<meta charset="UTF-8">
<title>style 样 式 </title>
</head>
<body>
<h2 id="con">l love ]avaScript</h2>
<p> JavaScript使网页显示动态效桌并实现与用户交互功能。</p>
<script type="text/javascript">
function mydisplay() {
var mycha = document.getElementById('con');
mycha.style.color = 'red';
mycha.style.backgroundColor = '#CCC';
mycha.style.display = 'none';
}
</script>
<input type="button" value="隐藏内容" onclick='mydisplay()'>
</body>
</html>
举报