js 事件點擊 顯示 隱藏


 

 1       <div style="position:absolute;left:40%;top:10%;border-style:dotted">
 2           <img src="zgl.jpg"/><br/>
 3           <center>
 4               <input type="button" value="隱藏"/>
 5                   &nbsp;&nbsp;&nbsp;&nbsp;
 6               <input type="button" value="顯示"/>
 7           </center>
 8       </div>
 9       <script type="text/javascript">
10           document.getElementsByTagName("input")[0].onclick=function(){
11               //將圖像隱藏
12               var imgElement = document.images[0];
13               imgElement.style.visibility="hidden";
14           }
15           document.getElementsByTagName("input")[1].onclick=function(){
16               //將圖像顯示
17               var imgElement = document.images[0];
18               imgElement.style.visibility="visible";
19           }
20           document.getElementsByTagName("div")[0].onmouseover=function(){
21               //將圖片放大
22               var imgElement = document.images[0];
23               //獲取原來圖片的大小
24               x = imgElement.width;
25               y = imgElement.height;
26               imgElement.width=imgElement.width*1.5;
27               imgElement.height=imgElement.height*1.5;
28           }
29           document.getElementsByTagName("div")[0].onmouseout=function(){
30               //將圖片還原
31               var imgElement = document.images[0];
32               imgElement.width=x;
33               imgElement.height=y;
34           }
35           //全局變量
36           var x;
37           var y;
38       </script>

 


免責聲明!

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



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