用Javascript显示隐藏层<!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>Ajax的Hello页面</title>
<link href="css/hello.css" rel="stylesheet" type="text/css" /> 

<script language="javascript">
 function ShowHide(button)
 {
  if(button.value=="隐藏")
  {
   button.value="显示";
   document.getElementById('good').style.display = "none";   //隐藏
  }
  else
  {
   button.value="隐藏";
   document.getElementById('good').style.display = "block";   //显示
  }
 }
</script>
</head>

<body>
<div />
</form>
</body>
</html>

将以上代码复制到一个新建的HTML页面中,即可实现“我要显示的文字”这句话的隐藏和显示。

关键就是下面两行代码:

document.getElementById('good').style.display = "none";   //隐藏

document.getElementById('good').style.display = "block";   //显示

下面是运行的效果:

用Javascript显示隐藏层

点“隐藏”之后的效果:

用Javascript显示隐藏层

相关文章:

  • 2021-11-29
  • 2021-11-12
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2021-06-21
猜你喜欢
  • 2022-12-23
  • 2021-06-07
  • 2021-12-14
  • 2021-06-08
  • 2021-08-17
  • 2022-02-11
  • 2022-01-20
相关资源
相似解决方案