When document is ready, there is a button that gets a new class names frame1. I want to set another class on this button after two seconds.
$(document).ready(function () {
setTimeout(function () {
$('#button').addClass('frame1')
}, 2000);
});
I want to add another class ‘frame2’ after two seconds if that is possible?
If you just want to add a class every coule of seconds until you have no more classes to add, you could use an interval and then clear it when the classes have all been added:
Fiddle: http://jsfiddle.net/EvXPy/
Or you could simply iterate over your array of class names and set timeouts from there:
Note that the first effect will run immediately since
iis equal to the index of0, meaning the timeout happens instantly. If you want this to be delayed, you can incrementias you see fit before multiplying by 2000.Fiddle: http://jsfiddle.net/EvXPy/1/