jquery draggable options

后端 未结 6 1546
梦谈多话
梦谈多话 2021-01-11 15:48

i want the draggable object to revert back to its original position when i click a button. i used \'destroy\' option but it doesnt seem to work. it disables the dragging but

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-11 16:16

    Revert executes when dragging has stopped (with optional delay), not on click.

    $(document).ready(function() {
       var originalTop = $('#draggable').position().top;
       var originalLeft = $('#draggable').position().left;
    
       $('#Zoom').toggle(
             function() {
                $("#draggable").draggable({});},
             function() {
                $("#draggable").draggable('destroy');
                $('#draggable').position().top = originalTop;
                $('#draggable').position().left= originalLeft;
             });
    });
    

提交回复
热议问题