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 drag, but not the span?
The dragstart event is on the div.
I'm probably overlooking something simple. I tried draggable=true on the div, and draggable=false on the span. That didn't work. Tried returning false on dragstart, that didn't work either.
dragstart (roughly):
var jTarget = $(e.target);
if ((jTarget.is('div.header') || (jTarget.parents('div.header'))
&& !jTarget.is('a, input, span')))
{
e.originalEvent.dataTransfer.setData("Text", "test");
}
else
{
if(e.preventBubble)
e.preventBubble();
if(e.stopPropagation)
e.stopPropagation();
return false;//???
}
The if else portion works as I expect, but I cannot get anything to stop the drag and allow the select.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…