views:

22

answers:

1

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():

http://api.jquery.com/width/

jQuery is becoming very popular and even used by big corporations, so you can consider using it.

動靜能量
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