HTML Code:
<html>
<head>
<script type="text/javascript">
function count(divid) {
var divh = document.getElementById(divid).offsetHeight;
alert(divh +"px " +divid);
function doit(divid, divh){
var p=divh;
while (p >= 0){
setTimeout("whatis('"+divid+"',"+p+");", 1000);
var p=p-1;}
}
doit(divid, divh);
}
function whatis(divid, divh){
document.getElementById('p').innerHTML=divh;
document.getElementById(divid).style.height=divh;};
</script>
</head>
<body>
<div id="top" class="top" style="width:300px; overflow:hidden;">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent blandit venenatis purus.
Integer massa libero, vehicula id, consequat sed, tincidunt nec, purus. Class aptent taciti
sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Suspendisse potenti.
</div>
<br><br>
<input type="button" value="ggg" onClick="count('top');">
<div id="p"></div>
</body>
</html>
This doesn't seem to work but I'm not sure how I could achieve it any other way. The setTimeOut doesn't wait one second before removing the next pixel.
I'm new to setTimeout, any idea where I'm going wrong?
In the unlikely event that you don't know what I'm trying to do, I'm trying to get the pixel height of the div to lower every half second.
Last edited by Petsmacker; 11-30-2008 at 02:01 PM..
|