...

View Full Version : Expand Div



mark87
12-17-2005, 08:37 PM
How can I use javascript to make a div expand (say, in width), but make it more like an animation, so perhaps every so many milliseconds the div would grow by 1px until it reached the certain width needed?

Osiris
12-17-2005, 09:32 PM
function expand_div(divID) {
var theDiv = document.getElementById(divID);
theDiv.width = theDiv.width + 1;
if(theDiv.width > 1024) { // Insert whatever width you want it to stop at here.
return;
} else {
setTimeout('expand_div('+divID+')', 250); // Set to do it every half-second. Again, insert whatever time you want.
}
}


I didn't actually test it, but it SHOULD work. If not, let me know.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum