gpt4 book ai didi

javascript - mouseover 和 Dragstart 有不同的目标

转载 作者:行者123 更新时间:2023-11-28 04:31:37 29 4
gpt4 key购买 nike

我正在处理以下格式的 html:

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

当我将鼠标放在第一个 div 上时,鼠标悬停事件的目标是该 div,但是当我拖动该 div 时,目标成为整个标签。有没有办法将拖动目标设置为 div 而不是整个链接?

最佳答案

您的 HTML 似乎无效

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?

draggable="true" 添加到元素(HTML5 功能)

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>

关于javascript - mouseover 和 Dragstart 有不同的目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44575825/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com