jQuery输入prob通过单击输入禁用false [英] jQuery input prob disable false by clicking the input
本文介绍了jQuery输入prob通过单击输入禁用false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过点击一个输入元素,道具,禁用是假的,但这不工作。
i want by clicking on an input element, that the prop, "disabled" is getting false, but this is not working.
来设置所有的输入。准备禁用 - > true正在工作。
to set all input on .ready to "disabled" -> true is working.
<script>
$(document).ready(function() {
$("input").prop("disabled", true); // this is working
});
$("input").click(function() {
$(this).prop("disabled", false); // this is not working
});
</script>
解决方案/编辑不允许对自己的问题使用答案按钮):
我找到了一个更好的解决方案。
使用readonly而不是disabled来完成作业。
I found a better solution. Using "readonly" instead of "disabled" does the job.
<script>
$(document).ready(function() {
$("input").prop("readonly", true);
$("input").click(function() {
$(this).prop("readonly", false);
});
});
</script>
推荐答案
似乎您的逻辑已还原。 Disabled = true
表示实际上该元素被禁用(不可点击)。尝试此方法:
Seems like your logic is reverted. Disabled=true
means actually that element is disabled (not clickable). Try this way:
$(document).ready(function() {
$(this).removeProp("disabled");
$("input").click(function() {
$("input").prop("disabled", "disabled");
});
});
这篇关于jQuery输入prob通过单击输入禁用false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文