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
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
Use toggleClass() with setInterval()
jQuery(function () {
var $div = $('.demo1');
setInterval(function () {
$div.toggleClass('demo1 demo2');
}, 1000);
})
Demo: Fiddle