簡體   English   中英

iPad無法選擇文本輸入中的所有文本

[英]iPad not selecting all text inside a text input on tap

好吧,這似乎是一個簡單的請求,但我發現它不是這樣。 我只是想要它,所以當html輸入[type =“text”]被聚焦(在ios中點擊)時,所有文本都被選中(就像任何普通的瀏覽器一樣)。 我環顧四周,發現了一些建議,但似乎沒有任何效果 - 這就是我嘗試過的:

$('input[type="text"], textarea').focus(function() {
    $(this).setSelectionRange(0, 9999);
}).mouseup(function(e){
    e.preventDefault();
});

還試過這個:

$('input[type="text"], textarea').focus(function() {
    $(this).select();
}).mouseup(function(e){
    e.preventDefault();
});

我已經讀過ios上的mouseup事件做了時髦的東西,但我不確定。 有任何想法嗎?

為什么不使用jQuery Mobile tap事件:

$(document).ready(function() {
    $("input[type=text], textarea").on("tap", function() {
        this.select();
    }).vmouseup(function(e){
        e.preventDefault();
    })
});

我相信它應該是

$('input[type="text"], textarea').focus(function() {
    this.select(); //no jquery wrapper
}).mouseup(function(e){
    e.preventDefault();
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM