PDA

View Full Version : Sliding drop down menu



Camerata
04-15-2010, 06:12 PM
Hey everybody, Ive tried to write a sliding drop down menu, but the text inside the div dont disappear in the right time. look:

<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!

vwphillips
04-15-2010, 08:29 PM
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);

}

Camerata
04-16-2010, 01:53 AM
Hey man, thank you so much!