google-chrome - 如何使用 GreaseMonkey/TamperMonkey 更改文本字段的输入属性?
问题描述
如何从此输入字段中删除只读属性?
<input class=" calendar_field" id="zoom_meeting_room[scheduled_on]" name="zoom_meeting_room[scheduled_on]" readonly="readonly" type="text" value="2020-11-07 12:08">
谢谢
解决方案
这是一个例子:
document.querySelector('#zoom_meeting_room[scheduled_on]').removeAttribute('readonly');
或者
document.getElementById('zoom_meeting_room[scheduled_on]').removeAttribute('readonly');
为了避免错误
const input = document.getElementById('zoom_meeting_room[scheduled_on]');
if (input) { input.removeAttribute('readonly'); }
或者
const input = document.getElementById('zoom_meeting_room[scheduled_on]');
input && input.removeAttribute('readonly');
您也可以将其设置为false
const input = document.getElementById('zoom_meeting_room[scheduled_on]');
if (input) { input.readOnly = false; }
或者
const input = document.getElementById('zoom_meeting_room[scheduled_on]');
if (input) { input.setAttribute('readonly', false); }
推荐阅读
- google-chrome-extension - 没有 [空格] 或 [制表符] 的 chrome 扩展多功能框快捷关键字
- python - 根据另一列的类别计算列中特定值的出现次数
- python - 如何将 numpy 数组转换为 numpy 元组数组?
- excel - 需要编写excel函数来遍历工作簿中的所有工作表,然后返回单元格中的所有值
- c++ - 我找不到 ContextMenuItem 的 ID
- excel - 使用单元格属性复制范围时出现应用程序/对象错误
- c++ - 嵌套虚函数
- chainlink - Naas.link 的运行问题
- javascript - 帮助创建按钮对表格进行排序
- python - 使用两个不同的分隔符将字符串拆分为列表