耳朵里咚咚响像心跳:jsp 的显示和隐藏问题

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/09 18:00:57
请问在jsp中,如果有一个按钮和一行字,按钮一开始叫“详细”,点一下,那行字就出来了,然后按钮名字变成“简单”,再点一下字就消失了,按钮名字变回“详细”,就一个页面,不用跳转到其他页面。请问这个功能怎么做,谢谢。

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function showInfo(){
if(document.all.showBtn.value=="简单"){
document.all.showBtn.value = "详细";
document.all.infoDiv.style.visibility = "hidden";
}else{
document.all.showBtn.value = "简单";
document.all.infoDiv.style.visibility = "visible";
}
}
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<div id="infoDiv">此处显示你自己的内容</div>
<input type="button" name = "showBtn" value="简单" onclick="showInfo()"/>
</form>
</body>
</html>