gpt4 book ai didi

javascript - pointerEvent = "none"不会禁用输入标签

转载 作者:行者123 更新时间:2023-12-03 01:37:10 24 4
gpt4 key购买 nike

尝试使用pointerEvents = "none"; 来禁用插入的可输入性。它似乎根本不起作用。禁用时“实际”也不起作用。

function enter() {
document.getElementById('actual').pointerEvents = "none";
}
<div id="actual">
<div id="mastsactual"><input id="sign1" disabled></input>
</div>
</div>

最佳答案

当然,#actual 不再“工作”了,因为您对其应用了 pointerEvents='none'

如果您只想禁用 input 元素,请尝试以下操作:

function enter() {
element = document.getElementById('sign1')
element.disabled = element.disabled ? false : true
button = document.getElementById('button')
button.value = button.value === 'Disable Input' ? 'Enable Input' : 'Disable Input'
}
<div id="actual">
<div id="mastsactual">
<input id="sign1" type="text">
</div>
</div>
<input id="button" type="button" onClick=enter() value="Disable Input">

调用 enter 函数将切换 sign1 的状态,因此,如果启用它,它将变为禁用,反之亦然。

关于javascript - pointerEvent = "none"不会禁用输入标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51015637/

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