Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
你好朋友我想知道我是否可以使用jquery可拖动插件来更新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/