So I have a ul
with its li's
.
I would like to make a js
so that every li
appears and disappears ( automatically in an infinite loop ) to make way for the next li
. That is, every li
appears in sequence.
Something of the Type:
HTML
<ul>
<li> 1 </li>
<li> 2 </li>
<li class="ativa"> 3 </li>
<li> 4 </li>
</ul>
...
<ul>
<li> 1 </li>
<li> 2 </li>
<li> 3 </li>
<li class="ativa"> 4 </li>
</ul>
CSS:
li{
opacity:0;
}
.ativa {
opacity:1;
}
Any tips? Thanks to anyone who could help!
Add:
So, I did this jQuery
$(document).ready(function(e) {
function addcls() {
var li = $(".cycle-slideshow div.atividades ul li.ativa");
li.removeClass('ativa');
var current = li.removeClass('ativa');
next = current.next().length ? current.next() : current.siblings().filter(':first');
next.addClass('ativa');
};
setInterval(function () {
addcls();
}, 2000);
});
And the css, like this:
div.atividades ul li{
display:none;
vertical-align:middle;
line-height:100px;
position:absolute;
border:.1px #000 solid;
width:100%;
text-align:center;
font-size:36px;
}
.ativa {
display:block;
}
What is giving error is that when I do:
div.atividades ul li{
display:none;
all the lines are gone: obviously. However, when I do
next.addClass('ativa');
Although in spectrum lis
are gaining and losing classe ativa
usually by javascript , display: block
does not occur