[英]How do I drag a div if someone clicks on a input within the `draggable` div?
我有以下html和js(查看下面的jsfiddle)。
我将dom准备好的jquery拖动事件绑定到.control-group
。
如果用户点击并拖动除输入之外的任何地方(在div内),他们可以按预期拖动div,但如果他们点击输入,则会选择输入文本的输入,(并且不允许我们拖动它)。
我希望能够让用户单击div中的ANYTHING,并且应该可以拖动WHOLE 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 Ready):
$('.control-group').draggable();
所以我正在寻找事件来“冒泡”到.control-group
div。 (如果我做对了吗?!)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.