How do I prevent drag on a child, but allow drag on the parent?

前端 未结 6 1064
情深已故
情深已故 2020-12-07 00:33

I have a div which the user can drag, inside that div is a span with some text which I want to allow the user to select (thus they cannot drag it). How do I allow the div to

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-07 01:26

    just posting in case someone searches for it with a similar Problem

    element.addEventListener('mousedown', function() { this.parentNode.setAttribute("draggable", false); });
    element.addEventListener('mouseup', function() { this.parentNode.setAttribute("draggable", true); });
    

    worked for me

提交回复
热议问题