问题
i want by clicking on an input element, that the prop, "disabled" is getting false, but this is not working.
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>
SOLUTION / EDIT (sorry I am not allowed to use the answer-button on my own question):
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>
回答1:
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");
});
});
来源:https://stackoverflow.com/questions/18485231/jquery-input-prob-disable-false-by-clicking-the-input