【发布时间】:2017-06-28 07:44:55
【问题描述】:
我想在一个 Div 中切换所有输入的只读属性。 我找到了一些解决方案,但只有一个有效。
我想知道为什么这段代码不起作用:
$("#" + id + " :input").each( function() {
$(this).readOnly = !$(this).readOnly;
});
这是工作代码:
$("#" + id + " :input").each( function() {
(this).attr("disabled", function(i, d) {
return !d;
});
});
谁能给我解释一下?
【问题讨论】:
标签: javascript jquery toggle readonly