3

拖动对象时,用户可以在 x 和 y 轴上拖动。我想将可拖动性限制为仅 x 轴。我该怎么做呢?

谢谢!

4

1 回答 1

12

查看选项:

“限制拖动到水平 (x) 或垂直 (y) 轴。可能的值:'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');
于 2010-07-21T03:56:36.400 回答