朋友们好,我想知道我是否可以使用jquery draggable插件来更新margin-left和margin-top属性。默认情况下,它会在拖动事件时更新css的left和top属性。请帮助
当然可以
$( "#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/