如果单击其他内容,则最后一个输入(已单击)应为readonly - >再次成真。
这是我的代码:
<script>
$(document).ready(function() {
$("input").prop("readonly", true);
$("input").click(function() {
$(this).prop("readonly", false);
});
});
</script>
谢谢!
答案 0 :(得分:1)
试试这个
--to make input editable on click
$('input').bind('click', function () {
$(this).prop("readonly", false);
});
--to make input readonly on lost focus
$('input').bind('blur', function () {
$(this).prop("readonly", true);
});
答案 1 :(得分:0)
$("input").click(function() {
var $that = $(this);
$("input").each(function() {
if ($(this) !== $that) {
$(this).prop("readonly", false);
}
});
});
答案 2 :(得分:0)
尝试
$("input").attr("readonly", "readonly");