[jQuery] toggle() animation - maybe there is a neater way to do this?
I have this code shown below - it works fine but I imagine there is a
neater way to accomplish this... anyone?
I would love to somehow shrink this to less lines of code.
stoggle = 0;
$("#button").).click(function(){
var extra = 150;
if(stoggle==0){
$('#div').animate({top:parseInt($('#div').css('top'))+extra},400);
stoggle = 1;
}else{
$('#div').animate({top:parseInt($('#div').css('top'))-extra},400);
stoggle = 0;
}
});