这样可吧!
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>style样式</title>
</head>
<body>
<h2 id="con">I love JavaScript</H2>
<p> JavaScript使网页显示动态效果并实现与用户交互功能。</p>
不可少的工具。</p>
<form>
<input type="button" onclick="hidetext()" value="隐藏内容" />
</form>
<script type="text/javascript">
var n = document.getElementById("con");
n.style.color="red";
n.style.backgroundColor ="#ccc";
function hidetext(){
varn = document.getElementById("con");
n.style.display="none";
}
</script>
</body>
</html>