js相关资料

29 Jul 2013, by

JavaScript面向对象与原型

jquery-sidebar

var sidebar = $(".sidebar");
var width = sidebar.outerWidth();
var height = sidebar.outerHeight();
var isClosed = false;

sidebar.on("click", function () {
  _this = $(this);
  if (isClosed) {
    _this.stop().animate({left: 0}, 200, function(){
      isClosed = false;
    });
  } else {
    _this.stop().animate({left: -sidebar.outerWidth()}, 200, function(){
      isClosed = true;
    });
  }
});