【问题标题】:do not allow to drag when input is in use or clicked [duplicate]输入正在使用或单击时不允许拖动[重复]
【发布时间】:2017-06-19 11:55:51
【问题描述】:

我不希望在输入时拖动 div。

例如:当我在输入中有一些文本并尝试突出显示它时,它不会突出显示它;而是拖动 div

https://jsfiddle.net/213r38rL/

<div id="select1" draggable="true" ondragstart="start(event)" ondragend="end(event)">
  SELECT
  <input type="text" name="select" id="selectinput">

</div>

【问题讨论】:

标签: javascript html


【解决方案1】:

您可以在focusfocusout 事件中设置draggable=false

<div id="select1" draggable="true" ondragstart="start(event)" ondragend="end(event)">
  SELECT
  <input onfocus="document.getElementById('select1').draggable=false;" onfocusout="document.getElementById('select1').draggable=true;" type="text" name="select" id="selectinput">

</div>

【讨论】:

    猜你喜欢
    • 2017-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-17
    • 2011-06-01
    • 2012-01-04
    相关资源
    最近更新 更多