jQuery code does not work on iOS

落花浮王杯 提交于 2020-01-24 23:59:49

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!