将可用的输入从true更改为false时,为什么不能单击输入?

时间:2019-05-23 02:25:59

标签: javascript

我有一个将输入属性从true更改为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);

1 个答案:

答案 0 :(得分:2)

您需要使用removeAttribute禁用。

playerLocation.removeAttribute('disabled');
<input id="playerLocation" type="text" name="location" oninput="setPlayerLocation()" disabled="true">