0
So I have a ul
with their li's
.
I’d like to make a js
so that each li
appeared and disappeared (automatically in an infinite cycle) to make way for the next li
. That is, that each li
appears in sequence.
something like:
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 made 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’s going wrong is that when I do:
div.atividades ul li{
display:none;
all lines disappear: obviously. But when I do
next.addClass('ativa');
Although in the spectrum as lis
are winning and losing the classe ativa
usually by javascript, the display: block
does not occur
Like a merry-go-round?
– Lucas Guima
If you have a specific number of lines (if it’s always the same number of lines) you can only do it with CSS without needing JS by just doing a simple animation with CSS. If you’re interested I can make an example and answer you.
– hugocsl
sure want.
– Carlos Rocha