只用一个按键显示隐藏,怎么弄
<p id="by" >sssssssssssssssssss</p>
<input id="btn" type="button" value="点击隐藏" onclick="ove()">
<script>
function ove(){
var bb = document.getElementById('by');
if(bb.style.display !='none'){
bb.style.display='none';
btn.value="显示内容";
}else{
bb.style.display='block';
btn.value="点击隐藏";
}
}
</script>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset="UTF-8">
<title>display</title>
<script type="text/javascript">
var i=0;
function modifytext()
{
if(i%2==0)
{
con.style.display="none";
btn.value="显示内容";
i++;
}
else
{
con.style.display="block";
btn.value="隐藏内容";
i++;
}
}
</script>
</head>
<body>
<h1>JavaScript</h1>
<p id="con">做为一个Web开发师来说,如果你想提供漂亮的网页、令用户满意的上网体验,JavaScript是必不可少的工具。</p>
<form>
<input type="button" id="btn" onclick="modifytext()" value="隐藏内容" />
</form>
</body>
</html>
<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset="UTF-8"><title>display</title> <script type="text/javascript"> var i=0; function modifytext() { if(i%2==0) { con.style.display="none"; btn.value="显示内容"; i++; } else { con.style.display="block"; btn.value="隐藏内容"; i++; } } </script> </head> <body> <h1>JavaScript</h1> <p id="con">做为一个Web开发师来说,如果你想提供漂亮的网页、令用户满意的上网体验,JavaScript是必不可少的工具。</p> <form> <input type="button" id="btn" onclick="modifytext()" value="隐藏内容" /> </form></body> </html>
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<p id="clear">刮风这天,我喜欢握着你手</p>
<form>
<input type="button" value="显示/隐藏" onclick="modify()"/>
</form>
<script>
var s=1;
function modify()
{
if(s==1)
{
document.getElementById('clear').style.display = 'none';
s=2;
}
else if(s==2)
{
document.getElementById('clear').style.display='block';
s=1;
}
}
</script>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>className属性</title>
</head>
<body>
<p id="p1" > JavaScript使网页显示动态效果并实现与用户交互功能。</p>
<input type="button" value="更改外观" onclick="modify()"/>
<script type="text/javascript">
function add(){
var p1 = document.getElementById("p1");
p1.style.display="none"
}
function modify(){
var p2 = document.getElementById("p2");
p2.style.display="block"
}
</script>
</body>
</html>