我有以下 html 和 js(查看下面的 jsfiddle)。
我已经将 dom 上的 jquery 拖动事件绑定(bind)准备好 .control-group
。
如果用户单击并拖动输入框以外的任何地方(在 div 内),他们可以按预期拖动 div,但如果他们单击输入框,它会选择输入框来输入文本,(并且不允许我们拖动它)。
我希望能够让用户点击 div 中的任何内容,并且应该能够拖动整个 div。
<div class="control-group">
<label class="control-label" for="textInput">Text Input</label>
<div class="controls">
<!-- If someone clicks on this input, the whole div should still be draggable -->
<!-- Its ok if the input is not usable, thats the point!, Its just for show -->
<input id="textInput" name="textInput" type="text" placeholder="placeholder"/>
<p class="help-block">you have an error!</p>
</div>
</div>
jQuery(Dom 就绪):
$('.control-group').draggable();
所以我正在寻找“冒泡”到 .control-group
div 的事件。 (如果我没记错的话?!)
最佳答案
关于javascript - 如果有人单击 `draggable` div 中的输入,我该如何拖动 div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21816262/