div 위아래 슬라이드(숨기기/표시)

1493 단어 div

   
    <script type="text/javascript">
    	 function changeDivDown(){//      div   
    		var d = document.getElementById("TLDiv");
			var h = d.offsetHeight;
			var maxh=250;
			function dmove(){
							
				h+=5;//     
				if(h>=maxh){
					d.style.height='250px';
					clearInterval(iIntervalId);
				}else{
					d.style.display='block';
					d.style.height=h+'px';
				}
			}
			iIntervalId=setInterval(dmove,2);//      
		}
		function changeDivUp(){//  div       
    		var d = document.getElementById("TLDiv");
			var h = d.offsetHeight;
			var maxh=250;
			function dmove(){
				h-=5;//     
				if(h<=50){
					d.style.display='block';
						
					clearInterval(iIntervalId);
				}else{
					d.style.height=h+'px';
				}
			}
			iIntervalId=setInterval(dmove,2);      
		}
    </script>



<div id="TLDiv" style="width: 960px;height: 250px;margin-bottom: 10px;overflow: hidden;border:1px solid red;">
      /    div   
</div>

<input type="button" value="  " onclick="changeDivDown()"/>
<input type="button" value="  " onclick="changeDivUp()"/>

좋은 웹페이지 즐겨찾기