[设置属性值]
//setter
$(‘.selector’).draggable(‘option’, ‘appendTo’, ‘body’);.
axis:
[类型]String, Boolean(可取的值有’x’, ‘y’, false)
‘x’: 只能水平拖动
‘y’: 只能垂直拖动
false: 既可以水平, 也可以垂直拖动.
[默认值]false, 不限制拖动的方向
[产生影响]
约束拖动过程中的取向.
[代码示例]
[初始化]
$(‘.selector’).draggable({ axis: ‘x’ });
[获取属性值]
var axis = $(‘.selector’).draggable(‘option’, ‘axis’);
[设置属性值]
$(‘.selector’).draggable(‘option’, ‘axis’, ‘x’);
cancel:
[类型]选择器
[默认值]’:input, option’
[产生影响]
通过选择器指定这类元素不能被渲染成draggable控件.
[代码示例]
[初始化]
$(‘.selector’).draggable({ cancel: ‘button’ });
[获取属性值]
var cancel = $(‘.selector’).draggable(‘option’, ‘cancel’);
[设置属性值]
$(‘.selector’).draggable(‘option’, ‘cancel’, ‘button’);
connectToSortable: 此选项需要和sortable联合工作, 再议.
[类型]选择器
[默认值]’:input, option’
[产生影响]
通过选择器指定这类元素不能被渲染成draggable控件.
[代码示例]
[初始化]
$(‘.selector’).draggable({ cancel: ‘button’ });
[获取属性值]
var cancel = $(‘.selector’).draggable(‘option’, ‘cancel’);
[设置属性值]
$(‘.selector’).draggable(‘option’, ‘cancel’, ‘button’);
containment:
[类型]选择器, 元素, 字符串, 数组.
选择器: 只能在选择器约束的元素内拖动
元素: 只能在给定的元素内拖动
字符串:
parent: 只能在父容器内拖动
document: 在当前html文档的document下可拖动, 超出浏览器窗口范围时, 自动出现滚动条
widow: 只能在当前浏览器窗口的内容区域拖动, 拖动超出当前窗口范围, 不会导致出现滚动条…
数组: [x1, y1, x2, y2]以[开始水平坐标, 开始垂直坐标, 结束水平坐标, 结束垂直坐标]的方式划定一个区域, 只能在此区域内拖动. 这种方式指定时, 值是相对当前浏览器窗口内容区域左上角的偏移值.










