Jquery Ui Draggable更新不同的css属性

时间:2013-08-12 05:30:08

标签: php jquery

朋友们,我想知道我是否可以使用jquery draggable插件来更新margin-left和margin-top属性,默认情况下它会更新拖动事件中css的左侧和顶部属性。 请帮忙

1 个答案:

答案 0 :(得分:1)

当然可以

 $( "#box" ).draggable({
  stop: function( event, ui ) {

      $( "#box" ).css('margin-top',$("#box").offset().top).css('top',0);
      $( "#box" ).css('margin-left',$("#box").offset().left).css('left',0);

}
});

http://jsfiddle.net/CnDfF/3/