<!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使網(wǎng)頁顯示動態(tài)效果并實現(xiàn)與用戶交互功能。</p>
??<input?type="button"?value="sdfdfas"?onclick="hidden()"/>
??<script?type="text/javascript">
???var?i?=?document.getElementById("con");
???i.style.color="red";
???i.style.backgroundColor="#ccc";
???function?hidden(){
???????i.style.display="none";
???}
?
?
??</script>
</body>
</html>
2016-12-17
hidden是關(guān)鍵字,不能當(dāng)函數(shù)名 換一個其他字母就好啦?。?!
2016-12-11
我這又可以?
? <h2 id="con">I love JavaScript</h2>
? <p>JavaScript使網(wǎng)頁顯示動態(tài)效果并實現(xiàn)與用戶交互功能。</p>
? <input type="button" value="隱藏內(nèi)容" onclick="nshow()"/>
? <script type="text/javascript"> ??
? ? var tt=document.getElementById("con");
tt.style.backgroundClor="#CCC";
tt.style.color="red";
function nshow(){
? ? ?tt.style.display="none";
?} ??
? </script>
</body>
</html>