I am trying to create a text box where I can add HTML elements that need to be dragged at the character level. This question is related to the other that I am currently asking , but it is related to the GWT. To create such a text area, I am trying to figure out how to do this step by step. This is what I got so far:
Jsfiddle
JavaScript:
function smartdrag(e) { var id = e.target.getAttribute('id'); if (id!=='plzdragme' && id !== 'plzdragmeimg') { e.stopPropagation(); e.preventDefault(); return; } }
HTML:
<div contenteditable="true" ondragstart="smartdrag(event)"> More blah <img src="http://lorempizza.com/80/80/2" id="plzdragmeimg" draggable="true" class="fancy-img"/> about <span id="plzdragme" contenteditable="false" class="fancy" draggable="true">DRAGME</span> Sparta! </div>
But for some reason I can only drag img . Actually I need to drag a span or even a better div ..
How can i do this?
PS: Please do not use jQuery if possible.
javascript html
displayname Mar 24 '16 at 13:54 on 2016-03-24 13:54
source share