這樣可吧!
<!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>