在这里我遇到了困难,我在一个div上使用.draggable,它工作得很好,但我也需要一个链接,这样一旦用户将div拖到页面上的任何位置,他们就可以将它“重置”到它的原始位置。
$(function() {
if (! /iphone|ipad|ipod|android|blackberry/i.test(navigator.userAgent.toLowerCase())) {
$( "#race_charts_container" ).draggable({ revert: false, cancel: "#graphs_content"});
}
});
$("#btnReset").click(function() {
$("#race_charts_container").animate({
left: '+=50px',
top: '+=50px'
});
});发布于 2012-05-31 21:19:30
看看这个演示:http://jsfiddle.net/M8Ehe/1/
只需将顶部和左侧设置为0即可。
代码:
$(function() {
if (! /iphone|ipad|ipod|android|blackberry/i.test(navigator.userAgent.toLowerCase())) {
$( "#race_charts_container" ).draggable({ revert: false, cancel: "#graphs_content"});
}
});
$("#btnReset").click(function() {
$("#race_charts_container").animate({left:0,top:0});
});https://stackoverflow.com/questions/10834214
复制相似问题