I’m using jQuery-ui;
how can I do a ‘toggle’ of a ‘margin’
first I have ‘-160px’ and then I put ’33px ‘
I want to alternate with each click to ‘.LoginButton’
CSS
.MyBox {
font-family:Arial;
color:#FFF;
width: 400px;
height: 150px;
margin-top:-160px;
}
jQuery
$('.LoginButton').click(function () {
$('.MyBox').animate({
marginTop: '33px'
}, {
duration: 2000,
specialEasing: {
marginTop: 'easeOutBounce'
},
complete: function () {
}
});
});
thanks!!
Quick and dirty, this would work, although I doubt this is best practice.
Edit: I like zzzzBov’s suggestion, but I don’t think toggleClass() supports advanced animation such as
specialEasingor acompletioncallback.http://jqueryui.com/demos/toggleClass/