Your code has some problems but I imagine you want to do a slideshow effect, changing div.
You can do it like this:
$(function () {
var divs = $(".ItemLaco");
var mostra = 0;
function slide() {
mostra++;
if (mostra == divs.length) mostra = 0;
divs.removeClass('mostrar');
divs.eq(mostra).addClass('mostrar');
}
setInterval(slide, 2000);
});
jsFiddle: link
What you have% does not make sense, I do not understand what you want to do with it, so I can not fix anything.
In this.class
you should take a look this question / answer , it's the same problem, that is you have to pass a function as argument to setInterval
use / call x at x time.
Then you have setInterval
, it's not very clear what you want to do, but in jQuery methods applied to collections of elements are applied to all. For example as I used above $(".ItemLaco").each
remove the CSS class from all elements of this collection, even if some do not.
I used CSS classes to show and hide:
.ItemLaco {
display: none;
}
.mostrar {
display: block;
}
Because it's better this way, cleaner and everything is in CSS.