How can we increase or Decrease width of a DIV using setTimeout() ??
+1
A:
setTimeout(function() { document.getElementById('foo').style.width = '300px' },
2000);
a related blog and spec:
http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/
https://developer.mozilla.org/en/DOM/window.setTimeout
If you want to increase or decrease first by getting the current width, then you can look into clientWidth():
https://developer.mozilla.org/en/DOM/element.clientWidth
or use jQuery's width():
jQuery is becoming very popular and even used by big corporations, so you can consider using it.
動靜能量
2010-10-28 06:35:58
Thanks Buddy can you help me a bit more that lets suppose i want to make a progress bar effect i have a div who's width is 1 px in start and then i want to increase its width with 1 px with the help of setTimeout how can i do it? and its background is set to red already
PhpSeeker
2010-10-28 06:59:24