0
我想在鼠標下方更改子元素的索引,但不會中斷點擊事件。這可能嗎?當事件mousedown
和mouseup
事件發生在一個和相同的元件被處理是否可以在不中斷點擊事件的情況下重新排序子女onodouown
<script>
function mouseDownHandler(event) {
var p = event.currentTarget.parentNode;
p.appendChild(event.currentTarget);
}
</script>
<div style="position: absolute; left: 50px; top: 100px; width: 50px; height: 100px; background-color: red;" onmousedown="mouseDownHandler(event)" onclick="console.log('click 1')">This is a test</div>
<div style="position: absolute; left: 70px; top: 100px; width: 50px; height: 100px; background-color: blue;" onmousedown="mouseDownHandler(event)" onclick="console.log('click')">This is a test</div>
https://jsfiddle.net/9d2dvcqj/
這是怎麼斷的單擊事件? –
如果appendChild更改元素的索引,則不會觸發click事件。 (即使mouseDown和mouseUp仍然在目標上) –