岚澜
2016-09-05 23:34
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>display</title>
<script>
function hidetext(){
var mychar = document.getElementById("con").style.display="none";
}
function showtext(){
var mychar = document.getElementById("con").style.display="block";
}
</script>
</head>
<body>
<h1>JavaScript</h1>
<p id="con">做为一个Web开发师来说,如果你想提供漂亮的网页、令用户满意的上网体验,JavaScript是必不可少的工具。</p>
<form>
<input type="button" onclick="hidetext()" value="隐藏内容" />
<input type="button" onclick="showtext()" value="显示内容" />
</form>
</body>
</html>
var mychar = document.getElementById("con").style.display="none";不能这么写,
应该是:var mychar = document.getElementById("con");
mychar.style.display="none ";
JavaScript入门篇
739817 学习 · 9566 问题
相似问题