【发布时间】:2015-04-05 08:08:47
【问题描述】:
我有一个简单的输入框:
<input id="myInput" class="someClass"></input>
还有一些 JQuery 代码:
$(e.currentTarget).prop('readonly', true);
e.currentTarget 是 [object HTMLInputElement] 的 IE11 名称。
我只是想将此输入字段设置为只读。在 chrome 中该代码有效,但在 IE 中无效。 我已经试过了:
.prop('readonly','readonly');
.prop('readonly', '');
.attr('readonly', true);
但它们都不能在 IE11 中工作(在 chrome 中每个人都工作)
【问题讨论】:
-
你试过 .attr('readOnly', true); ??
-
@jrenk:如果
prop不起作用,attr将不起作用。 -
它工作正常。输入在 IE 中变为只读。 (我使用
$('input')作为选择器)。 -
@MrUpsidown:区别似乎在于相关字段是否具有焦点。
-
@T.J.Crowder 我没听懂。你的意思是IE这个领域仍然可以聚焦?
标签: javascript jquery google-chrome internet-explorer