0
I’m using this code to show and hide Ivs as you click. But it doesn’t show any transition and looks very "dry" when clicking. I don’t really know how to work Javascript, so I’m having problems.
function mostra(theId){
var theArray= new Array('thms', 'pgs');
w=document.getElementById(theId)
if(w.style.display=="block"){w.style.display='none';}else{
for(i=0; i<theArray.length; i++){
if(theArray[i] == theId){
w.style.display='block';
}else{
document.getElementById(theArray[i]).style.display='none';
}
}
}
}
#thms, #pgs{margin-top: 40px;}
.t, .p{cursor: pointer;}
<div class="menu">
<a onclick="mostra('thms')" class="t";>themes</a>
<a onclick="mostra('pgs');" class="p">pages</a>
</div>
<div id="thms" style="display:none;">
<ul>
<li><a href="/">all themes</a></li>
<li><a href="/">one column</a></li>
<li><a href="/">+two columns</a></li>
<li><a href="/">minimalist</a></li>
<li><a href="/">full sidebar</a></li>
<li><a href="/">infinite scroll</a></li>
<li><a href="/">load more</a></li>
<li><a href="/">250px</a></li>
<li><a href="/">400px</a></li>
<li><a href="/">500px</a></li>
<li><a href="/">540px</a></li>
<li><a href="/">multi post sizes</a></li>
</ul>
</div>
<div id="pgs" style="display:none;">
<ul>
<li><a href="/">all pages</a></li>
<li><a href="/">minimalist</a></li>
<li><a href="/">grid</a></li>
<li><a href="/">portifolio</a></li>
<li><a href="/">blogroll</a></li>
<li><a href="/">about</a></li>
<li><a href="/">all in one</a></li>
<li><a href="/">tags pages</a></li>
</ul>
</div>
jQuery is good at doing these things.
– Sam
There is a very cool and easy to move lib that might make your life easier to do this kind of work is called anime.js https://animejs.com/
– Diogo Santos Almeida