2017-06-19 29 views
0

我不想在输入时拖动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>

+0

开始和结束在哪里定义?你能编辑我制作的片段吗[mcve] – mplungjan

回答

1

您可以设置draggable=falsefocusfocusout事件:

<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>

相关问题