You could combine both marginLeft
and height
to be .animate()
d, like:
$("#btn1").one("click", function () {
var current_item = $("#div1");
current_item.css('margin-left', 0);
current_item.animate({
marginLeft: "20px",
height: "toggle"
}, 300, "swing");
});
DEMO: http://jsfiddle.net/sDrtE/
(yes, I meant to use .one()
and not .on()
, because it looks weird if you keep clicking the button)