http://jsfiddle.net/yHPTv/3/
Note. The example below does not work with newer versions of jQuery, as shown below for the example.
$(function () {
$("#clickme").toggle(function () {
$(this).parent().animate({right:'0px'}, {queue: false, duration: 500});
}, function () {
$(this).parent().animate({right:'-280px'}, {queue: false, duration: 500});
});
});
Change everything from left to right, then change the div and text content.
Also, give body a overflow-x: hiddento prevent a horizontal scroll bar.
A few minor updates make it compatible with the latest version:
$(function () {
var rightVal = -280;
$("#clickme").click(function () {
rightVal = (rightVal * -1) - 280;
$(this).parent().animate({right: rightVal + 'px'}, {queue: false, duration: 500});
});
});
http://jsfiddle.net/yHPTv/2968/
source
share