This article provides two on the JS control div display hidden code, using the Js+div ID to control the specified div is shown or hidden, let's look at two examples of this problem, the method is very simple.
<html>
<head>
<meta http-equiv= "Content-type" content= "html; charset=gb2312"/>
<title>js Control div display hidden </title>
<script language= "Web Effects" type= "Text/javascript"
<!--
Function Toggle (targetid) {
if (document.getElementById) {
Target=document.getelementbyid (Targetid);
if (target.style.display== "block") {
Target.style.display = "None";
} else {
target.style.display= "Block";
}
}
}
</script>
<style type= "Text/css
<!--
#div1 {
Background-color: #000000;
height:400px
width:400px;
Display:none;
}
;
</style>
</head>
<body>
<input type= "button" id= "Butn" value= "Show/Hide" onclick= "toggle (' Div1 ')"/>
<center>
<div id= "Div1" ></div></center>
Centered Div
</body>
</html>
Method Two
<html>
<head>
<title> Show and hide </title>
<script>
function dis (b) {
document.getElementById (' QQ '). Style.display = (document.getElementById (' QQ '). style.display== "Block")? "None": "Block";
B.value = (b.value== "display")? "Hide": "Show";
}
</script>
<style type= "Text/css"
#qq {display:none}
</style>
</head
<body>
<input type= "button" name= "Submit" value= "display" onclick= "dis (this)"
<div id= "QQ"
<table width= "height=" border= "0" cellpadding= "1" cellspacing= "1"
<tr>
<td width= "100%" bgcolor= "#3366ff" > content, this table is nested in the ID "qq" div </td
</TR>
</table>
</div>
</body>
</html>