【发布时间】:2013-08-31 08:51:26
【问题描述】:
我希望通过单击输入元素,道具“已禁用”变得错误,但这不起作用。
将 .ready 上的所有输入设置为“已禁用”-> true 有效。
<script>
$(document).ready(function() {
$("input").prop("disabled", true); // this is working
});
$("input").click(function() {
$(this).prop("disabled", false); // this is not working
});
</script>
解决方案/编辑(抱歉,我不允许在自己的问题上使用答案按钮):
我找到了更好的解决方案。 使用“只读”而不是“禁用”就可以了。
<script>
$(document).ready(function() {
$("input").prop("readonly", true);
$("input").click(function() {
$(this).prop("readonly", false);
});
});
</script>
【问题讨论】: