Results 1 to 3 of 3

Thread: Sliding drop down menu

  1. #1
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Sliding drop down menu

    Hey everybody, Ive tried to write a sliding drop down menu, but the text inside the div dont disappear in the right time. look:
    Code:
    <script>
    function aumenta(id) {
            target = document.getElementById(id);
          
              setInterval(function(){
                  
               		       new_size = target.style.height;
                                    
                   			new_size = new_size.split("px", 1);
                   			new_size -= 10;
                  			 new_size = new_size + "px";
                                    
    	       			target.style.height = new_size;
                   			//target.style.width = new_size;
    
    				if (new_size == "0px") {
    					document.getElementById(id).style.display = "none";
    					clearInterval();
    					return false;
    				}
    
    				
    			},1);
    		                      
    }
    
    </script>
    </head>
    
    <body >
    <div id="da" style="width:300px; height: 300px; background-color: #0066CC;" onmouseover="aumenta('da')">dDffffffffffffffffffdsdsd <br /> <br /> asdjksdkjn <br /> <br /> kjbskjdnas
    
    <input type="text" size="25" />
    </div>
    What can I do for fix it?
    The text disappear only when de the div disappeared completely...

    Thanks!

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,774
    Thanks
    2
    Thanked 410 Times in 405 Posts

    Default

    Code:
    function aumenta(id) {
            var target = document.getElementById(id);
            target.style.overflow='hidden';
            var i=  setInterval(function(){
    
               		       var new_size = target.style.height;
    
                   			new_size = new_size.split("px", 1);
                   			new_size -= 10;
                            if (new_size<0){
                             new_size=0
                            }
                  			new_size = new_size + "px";
    
    	       			target.style.height = new_size;
                   			//target.style.width = new_size;
    
    				if (new_size == "0px") {
    					document.getElementById(id).style.display = "none";
    					clearInterval(i);
    					return false;
    				}
    
    
    			},1);
    
    }
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hey man, thank you so much!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •