-1

I have two DIV class : demo1 and demo2

<div class="demo1">example text</div>

so How can i change div class name with every second : demo1 to demo2 and demo2 to demo1

Me7888
  • 1,191
  • 4
  • 17
  • 19
  • possible duplicate of [Toggle between two classes in jQuery](http://stackoverflow.com/questions/1644545/toggle-between-two-classes-in-jquery) – martynas Mar 01 '14 at 15:11

1 Answers1

4

Use toggleClass() with setInterval()

jQuery(function () {
    var $div = $('.demo1');
    setInterval(function () {
        $div.toggleClass('demo1 demo2');
    }, 1000);
})

Demo: Fiddle

Arun P Johny
  • 384,651
  • 66
  • 527
  • 531