View Full Version : Expand Div

12-17-2005, 09: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?

12-17-2005, 10: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.
} 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.