Change DIV class on timeout with JavaScript

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Change DIV class on timeout with JavaScript

Post 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!
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Change DIV class on timeout with JavaScript

Post 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')
User avatar
Syntac
Forum Contributor
Posts: 327
Joined: Sun Sep 14, 2008 7:59 pm

Re: Change DIV class on timeout with JavaScript

Post by Syntac »

This article covers the subject in detail.
Post Reply