1

I'm dealing with a html with the following format:

<a href = xxx> <div> div1 </div> <div> div2 </div> </a>

when I put my mouse over the first div, the target of my mouseover event is the div, but when I drag the div, the target becomes the tag as a whole. Is there a way to set the target of the drag to the div but not the entire link?

1 Answers1

0

Your HTML seems invalid

REF: HTML 5 states that the element "may be wrapped around entire paragraphs, lists, tables, and so forth, even entire sections, so long as there is no interactive content within (e.g. buttons or other links)".

REF: Is putting a div inside an anchor ever correct?

Add draggable="true" to the element (HTML5 feature)

draggable

The draggable global attribute is an enumerated attribute that indicates whether the element can be dragged, using the HTML Drag and Drop API. It can have the following values:

true, which indicates the element may be dragged

false, which indicates the element may not be dragged.

REF: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/draggable

<a href="">
  <div draggable="true"> div1 </div>
</a>
<a href="">
  <div draggable="true"> div2 </div>
</a>
Dalin Huang
  • 11,212
  • 5
  • 32
  • 49