我的函数将输入属性从真实变为false。DOM和CSS更新,但我仍然无法单击或使用输入。
<input id="playerLocation" type="text" name="location" oninput="setPlayerLocation()" disabled="true">
.player-details input[disabled="true"] {
opacity: 0.6;
}
playerLocation.setAttribute('disabled', false);
您需要使用removeAttribute
进行禁用。
playerLocation.removeAttribute('disabled');
<input id="playerLocation" type="text" name="location" oninput="setPlayerLocation()" disabled="true">