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);
解决方案
您需要removeAttribute
用于禁用。
playerLocation.removeAttribute('disabled');
<input id="playerLocation" type="text" name="location" oninput="setPlayerLocation()" disabled="true">
推荐阅读
- javascript - 使用 Symfony 和 Webpack 找不到 tarteaucitronjs
- xamarin.forms - 未在 Visual Studio 中列出的配置文件
- html - CSS:获取按钮和对齐
- excel - 如何从日期过滤器中删除时间
- python - 使用 Pandas 进行 Pivot 和 Groupby
- typescript - 我可以在 Typescript 中扩展接口的一部分吗?
- email - URL 查询字符串值在通过电子邮件发送后损坏
- karate - 有没有办法在使用空手道对 Ghatling 执行负载测试时将 API 响应存储到文件
- mongodb - 如何将默认值设置为填充的 3D 数组并仍然定义其中的对象?
- vue.js - 在元素(Vue)自动完成中选择后保持下拉