Prevent drag event to interfere with input elements in Firefox using HTML5 drag/drop

前端 未结 5 1262
猫巷女王i
猫巷女王i 2020-12-18 22:56

It seems that an input element loses a lot of functionality when put into an element with draggable=\"true\". This only seems to occur in firefox.

See my jsfiddle: h

5条回答
  •  隐瞒了意图╮
    2020-12-18 23:34

    See Firefox defect.

    As an alternative, setting the draggable="false" on input focus event and replacing back to draggable="true" on input blur event works.

    See jsfiddle for an example without any framework.

    HTML:

    JS:

    onFocus= function(e) {
        document.getElementById("draggableDiv").setAttribute("draggable", "false");
    }
    onBlur= function(e) {
        document.getElementById("draggableDiv").setAttribute("draggable", "true");
    }
    

提交回复
热议问题