问题
this code is working fine on desktop browsers, but on iOS (iPhone 5 / iOS 7) it doesn't. By clicking outside the clicked input, the clicked input does not get readonly->true again. UPDATED CODE:
<script>
$(document).ready(function () {
$("input").prop("readonly", true);
$('input').bind('click', function () {
$(this).prop("readonly", false);
});
$('input').bind('blur', function () {
$(this).prop("readonly", true);
});
});
</script>
回答1:
Use this for adding readonly attribute,
To add,
$("input").attr("readonly", "readonly");
To remove,
$("input").removeAttr("readonly");
This is the correct method
来源:https://stackoverflow.com/questions/18486676/jquery-code-does-not-work-on-ios