当我给文档一个mouseup
事件时,如果鼠标位于禁用的元素上并且我释放了按钮。无法触发文档mouseup
事件处理程序。我应该如何让处理程序被调用?
示例:
document.addEventListener('mouseup', () => {
console.log('mouseup')
}, true)
const changeBtn = document.getElementById('change')
const testBtn = document.getElementById('test')
changeBtn.onclick = () => {
testBtn.setAttribute('disabled', true)
}
testBtn.onclick = () => {
console.log('testBtn click')
}
<button id="test">test</button>
<button id="change">change</button>
在pointer-events: none
元素上使用CSS集pointer-events: none
:
:disabled
:disabled
document.addEventListener('mouseup', () => {
console.log('mouseup')
}, true)
const changeBtn = document.getElementById('change')
const testBtn = document.getElementById('test')
changeBtn.onclick = () => {
testBtn.setAttribute('disabled', true)
}
testBtn.onclick = () => {
console.log('testBtn click')
}