【问题标题】:Is there a way to limit the area which can be dragged?有没有办法限制可以拖动的区域?
【发布时间】:2016-07-01 15:37:07
【问题描述】:

正如您在JSFiddle 中看到的那样,我有一个可以拖动到整个身体的盒子。但是,是否只能在用户选择了id为head的紫色部分时才允许拖动它?

$(document).ready(function(){
    $( "#box" ).draggable({containment: "#container"});
});

【问题讨论】:

    标签: jquery css jquery-ui jquery-ui-draggable


    【解决方案1】:

    使用句柄

    $( ".selector" ).draggable({
      handle: "#head"
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-23
      • 1970-01-01
      • 2011-03-15
      • 2020-01-13
      • 1970-01-01
      相关资源
      最近更新 更多