javascript - Close div when new div opens -


i got slide how 1 div opens , when open recent div closes , new opens ?

$(function(){ $('#mybutton1').click(function(){     $('#thediv1').slidetoggle(); });}) 

i have 6 more of in real script.

close in common function , open 1 open are.

$(function(){     $('#mybutton1').click(function(){       closealldivs();       $('#thediv1').slidetoggle();     }); }) 

meanwhile, in other part of file...

function closealldivs(){       $('#thediv1').slidein(); //down/up/in/out whatever...       $('#thediv2').slidein();       $('#thediv3').slidein();       $('#thediv4').slidein();       $('#thediv5').slidein();       $('#thediv6').slidein();  } 

there more elegant solutions.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -