<!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> <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>
hidden是关键字,不能当函数名 换一个其他字母就好啦!!!