如何使用jQuery UI使元素可拖动,但不能使其子元素拖动? [英] How can I make an element draggable, but not its child elements, using jQuery UI?
本文介绍了如何使用jQuery UI使元素可拖动,但不能使其子元素拖动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,我想要这个:
<div class="draggable">
<p>Text that can be selected</p>
</div>
推荐答案
您可以使用cancel
选项,该选项接受可拖动对象的子元素的选择器,该选择器不应允许拖动:
You can use the cancel
option, which accepts a selector for child elements of the draggable object that should not allow dragging:
$('.draggable').draggable({cancel : 'p'});
这篇关于如何使用jQuery UI使元素可拖动,但不能使其子元素拖动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文