js 切換隱藏


 先試試

顯示\隱藏切換

腳本之家歡迎您

切換隱藏

 

 1 <style type="text/css">
 2 #thediv
 3 {
 4  width:200px;
 5  height:100px;
 6  line-height:100px;
 7  text-align:center;
 8  background-color:green;
 9 }
10 </style>
11 <script type="text/javascript">
12 function Show_Hidden(obj)
13 {
14  if(obj.style.display=="block")
15  {
16   obj.style.display='none';
17  }
18  else
19  {
20   obj.style.display='block';
21  }
22 }
23 window.onload=function()
24 {
25  var olink=document.getElementById("link");
26  var odiv=document.getElementById("thediv");
27  olink.onclick=function()
28  {
29   Show_Hidden(odiv);
30   return false;
31  }
32 }
33 </script>
34 </head>
35  <body>
36 <a href="#" id="link">顯示\隱藏切換</a>
37 <div id="thediv" style="display:block">腳本之家歡迎您</div>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM