I am currently in the process of creating a prototype for a quick dropdown menu using jQuery. However, I have reached the limits of my knowledge on jQuery and could use some assistance in solving my issue.
My objective is to have a dropdown animate down when a user hovers over a link, and when another link is clicked, the next dropdown will animate over the top, and so on.
Below is the HTML code:
<div class="wrapper">
<div class="dropdowns">
<ul>
<li class="call"><a href="#">Call</a></li>
<li class="chat"><a href="#">Chat</a></li>
<li class="message"><a href="#">Send a message</a></li>
</ul>
</div>
<div class="slide call-panel">
<h1>Call now</h1>
</div>
<div class="slide chat-panel">
<h1>Online chat</h1>
</div>
<div class="slide message-panel">
<h1>Send us a message</h1>
</div>
</div>
CSS:
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.wrapper {
max-width: 1200px;
margin: 0 auto;
}
.dropdowns {
overflow: hidden;
}
ul {
list-style: none;
margin: 0;
padding: 0;
}
li {
display: inline;
}
.call a {
background: #f1f1f1;
}
.chat a {
background: #e1e1e1;
}
.message a {
background: #f1f1f1;
}
a {
display: block;
width: 33.333%;
height: 50px;
line-height: 50px;
text-align: center;
float: left;
}
.call-panel {
height: 300px;
background: darkgrey;
display: none;
}
.chat-panel {
height: 300px;
background: darkgrey;
display: none;
}
.message-panel {
height: 300px;
background: darkgrey;
display: none;
}
h1 {
margin: 0;
padding: 0;
}
JS:
$( ".call a" ).click(function() {
toggleSlides( ".call-panel" );
});
$( ".chat a" ).click(function() {
toggleSlides( ".chat-panel" );
});
$( ".message a" ).click(function() {
toggleSlides( ".message-panel" );
});
function toggleSlides(slide){
$(".slide").slideUp ( "slow", function(){
$(slide).slideDown( "slow" );
} );
}
I have created a fiddle showcasing my current progress, but it seems to be having issues with animations. Any help would be greatly appreciated!