1 | initial version |
One way to restrict the area that can be grabbed for a draggable element is by using the "containment" option in the draggable function. This option allows you to specify a container element that the draggable element must stay within.
For example, if you have a draggable element that you want to be able to move only within a certain section of the page, you can set the containment option to the ID of that section's container element:
$("#draggable").draggable({
containment: "#container"
});
This will restrict the area that can be grabbed for the draggable element to the boundaries of the container element, preventing it from being dragged outside of that area.