javascript控制层显示或隐藏的方法
本文实例讲述了javascript控制层显示或隐藏的方法。分享给大家供大家参考。具体实现方法如下:
<html> <head> <title>中国风</title> <metahttp-equiv="Content-Type"content="text/html;charset=gb2312"> </head> <scriptlanguage="JavaScript"> functionshowLay1(){ lay1.style.visibility="visible"; lay2.style.visibility="hidden"; lay3.style.visibility="hidden"; } functionshowLay2(){ lay1.style.visibility="visible"; lay2.style.visibility="visible"; lay3.style.visibility="hidden"; } functionshowLay3(){ lay1.style.visibility="visible"; lay2.style.visibility="visible"; lay3.style.visibility="visible"; } </script> <body> <divid="lay1"style="position:absolute;left:60px;top:30px;width:250px;height:200px;index:1;visibility:visible">这是第一层内容,它的背景是透明的</div> <divid="lay2"style="position:absolute;left:60px;top:30px;width:250px;height:200px;index:2;visibility:hidden;background-color:silver">这是第二层内容,它的背景是灰色的</div> <divid="lay3"style="position:absolute;left:60px;top:30px;width:250px;height:200px;index:3;visibility:hidden"><br><br><br>这是第三层内容,它的背景是透明的</div> <formid="form1"style="position:absolute;left:70px;top:250px;"> <inputtype="button"value="第一层"onclick="showLay1()"> <inputtype="button"value="第二层"onclick="showLay2()"> <inputtype="button"value="第三层"onclick="showLay3()"> </form> </body> </html>
希望本文所述对大家的javascript程序设计有所帮助。