简体   繁体   English

移动浏览器中的jQuery .Select()将自动清除所有输入文本

[英]Jquery .Select() in mobile browser will auto clear all input text

I have create some input text and when I click the input text,it will auto select the input text. 我已经创建了一些输入文本,当我单击输入文本时,它将自动选择输入文本。 It is workable in desktop browser, however when I open it in the mobile browser such as Google Chrome , it will auto select input text and clear all the text in the input. 它可以在桌面浏览器中使用,但是当我在移动浏览器(例如Google Chrome打开它时,它将自动选择输入文本并清除输入中的所有文本。

$("input[type='text']").click(function () {
    $(this).focus();
    $(this).select();
    $(this).setSelectionRange(0, 999999999);

});

May I know is it have any solution for this condition, Thank You!!! 我想知道它对这种情况有什么解决办法吗,谢谢!!!

Finally, I have solve it, I have to specified which element id of my input text,and it workable for all device's browser. 最后,我解决了这个问题,必须指定输入文本的哪个元素ID,并且该元素可用于所有设备的浏览器。

$("#input1").click(function () {
    document.getElementById("input1").select();
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM