I want the panel to slide on the left side of the browser when I click a button and hide the panel when I click on the same button (toggle).
HTML
<div class="panel"> </div> <a href="javascript:void(0);" class="slider-arrow show">»</a>
CSS
.panel { width:300px; float:left; height:550px; background:#d9dada; position:relative; left:-300px; } .slider-arrow { padding:5px; width:10px; float:left; background:#d9dada; font:400 12px Arial, Helvetica, sans-serif; color:#000; text-decoration:none; position:relative; left:-300px; }
JQuery
$(function(){ $('.slider-arrow.show').click(function(){ $( ".slider-arrow, .panel" ).animate({ left: "+=300" }, 700, function() { // Animation complete. }); $(this).html('«').removeClass('show').addClass('hide'); }); $('.slider-arrow.hide').click(function(){ $( ".slider-arrow, .panel" ).animate({ left: "-=300" }, 700, function() { // Animation complete. }); $(this).html('»').removeClass('hide').addClass('show'); }); });
It shows the panel, but does not hide the panel. Any problem with the selectors used?
http://jsfiddle.net/Paramasivan/eHded/1/
source share