熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

javascript實現div的顯示和隱藏的小例子

2013-11-15 12:15:50  來源: JSP教程 

  代碼如下:
<html>
<head>
<meta httpequiv="ContentType" content="text/html; charset=gb" />
<title>oec</title>
<script language="JavaScript" type="text/JavaScript">
<!
function toggle(targetid){
if (documentgetElementById){
target=documentgetElementById(targetid);
if (targetstyledisplay=="block"){
targetstyledisplay="none";
} else {
targetstyledisplay="block";
}
}
}
>
</script>
<style type="text/css">
<!
#div{
backgroundcolor:#;
height:px;
width:px;
display:none;
}
>
</style>
</head>

  <body>
<input type="button" id="butn" value="顯示/隱藏" onclick="toggle(div)" />
<center>
<div id="div"></div></center>
居中的DIV
</body>
</html>


From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20600.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.