Reputation: 74520
Please look at my example on jsfiddle. The blue thing is supposed to slide right and back.
Help is certainly welcome!
Upvotes: 1
Views: 417
Reputation: 27839
Use data
to store the slide_out
variable in the element, and change 0px
to just 0
:
$(document).ready(function(){
$("#right_column").click(function(){
if(!$(this).data('slide_out')){
$("#right_column").animate({left:0},"slow");
$(this).data('slide_out', true);
}
if($(this).data('slide_out')){
$("#right_column").animate({left:-140},"slow");
$(this).data('slide_out', false);
}
});
});
Look at it working here.
Upvotes: 2
Reputation: 8046
Your referencing slideout like a php variable. Not a javascript one.
$(document).ready(function(){
var slide_out
$("#right_column").click(function(){
if(slide_out){
$("#right_column").animate({left:0px},"slow");
slide_out=true;
}
if(slide_out){
$("#right_column").animate({left:-140px},"slow");
slide_out=false;
}
});
});
Upvotes: 0