拖动对象时,用户可以在 x 轴和 y 轴上拖动。我想将可拖动性限制为仅在 x 轴上。我应该怎样做呢?
谢谢!
最佳答案
查看 axis选项:
"Constrains dragging to either the horizontal (x) or vertical (y) axis. Possible values: 'x', 'y'."
示例:
// Initialize a draggable with the axis option specified.
$( ".selector" ).draggable({ axis: 'x' });
// Get the axis option, after initialization.
var axis = $('.selector').draggable('option', 'axis');
// Set the axis option, after initialization.
$('.selector').draggable('option', 'axis', 'x');
关于javascript - jQueryUI 可拖动 : Constrain draggability to a single axis?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3296182/