Can I drag inputs and text fields?

The MDN specification, and every site I can find on Google, says that all HTML elements can be dragged and dropped. However, in practice, I found that I can not drag text inputs or text fields, even if they are disabled.

For example, with the following code:

<img src="http://www.placehold.it/350x150" draggable alt="Placeholder image">

<a href="http://example.com" draggable>Link</a>

<input type="text" draggable>
<input type="text" disabled draggable>

I can drag the image and link, but none of the inputs can be dragged.

Here is jsfiddle

Can I drag inputs using the HTML5 drag attribute? If not, is there a workaround I could use?

+4
source share
4 answers

, , , - div, , @james, .

, , , . , , Firefox.

, , <input> <textarea> ( div).

(http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#the-draggable-attribute) .

+1

MDN , draggable (.. ), :

, . ondragstart , .

+3

, JavaScript!

- draggable.js(http://gtramontina.imtqy.com/draggable.js/)

: http://jsfiddle.net/ttfrk/1/ .

draggable( document.getElementById('draggable') );

for document.getElementsByClassName .

+1

, , () .

, , , , draggable , mouseclick.

0

Source: https://habr.com/ru/post/1533013/


All Articles