jquery draggable: how to limit the draggable area?

后端 未结 5 2096
独厮守ぢ
独厮守ぢ 2020-12-01 04:58

I have a draggable object (div), and some droppable ones (table TD\'s). I want the user to drag my draggable object to one of those droppable TD\'s.

I enable draggab

5条回答
  •  没有蜡笔的小新
    2020-12-01 05:25

    Use the "containment" option:

    jQuery UI API - Draggable Widget - containment

    The documentation says it only accepts the values: 'parent', 'document', 'window', [x1, y1, x2, y2] but I seem to remember it will accept a selector such as '#container' too.

提交回复
热议问题