Page 1 of 1

Change DIV class on timeout with JavaScript

Posted: Sat Nov 29, 2008 10:00 am
by omniuni
So, I hope this is simple, I've spent the last hour trying to figure it out.

I want a DIV, currently that has two classes applied to it, to change to a different class after two seconds. So,

Code: Select all

<div class="class_one class_two">My Content</div>
should, after two seconds, become:

Code: Select all

<div class="new_class">My Content</div>
Since this is simple, I can just apply it inline... (using onLoad?)

Also, is there a way I can simply remove a DIV from the page after two seconds?

Thanks all!

Re: Change DIV class on timeout with JavaScript

Posted: Sat Nov 29, 2008 3:17 pm
by omniuni
I tried more variations on w3schools tryit editor, and although I can get a div to just disappear (say, onclick) I can't seem to make any delay work, nor do I know the best way to simply remove it completely (I just managed to change the visibility to 'hidden')

Re: Change DIV class on timeout with JavaScript

Posted: Sat Nov 29, 2008 3:23 pm
by Syntac
This article covers the subject in detail.