jQuery代码在iOS上不工作 [英] jQuery code does not work on iOS
本文介绍了jQuery代码在iOS上不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这段代码在桌面浏览器上正常工作,但在iOS(iPhone 5 / iOS 7)上却没有。
通过单击被点击的输入外,被点击的输入不会再次获得readonly-> true。 更新代码:
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>
推荐答案
使用此方法添加只读属性
Use this for adding readonly attribute,
要添加,
$("input").attr("readonly", "readonly");
要删除,
$("input").removeAttr("readonly");
这是正确的方法
这篇关于jQuery代码在iOS上不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文