Safari jQuery select () mobile for focus input not working

This issue concerns the iOS6 iPad in mobile Safari.

I do not want the text in the input file to be automatically selected when the user clicks on the input.

I have a solution that works in a normal browser, like Chrome:

        $(document).ready(function() {
        //Select text on focus for input
        $("input:text").focus(focustext);
    });
    function focustext() {
        var input = $(this);
        setTimeout(function() { 
            input.select();
        },100);
    }

But this does not work in Safari Mobile.

I read a few topics about this, for example: Workaround to Webkit [Chrome / Safari] javascript select focus error (when using tabs between fields) Select text in focus using jQuery not working on iPhone iPad Browsers

I tested the proposed solution in a simple dummy, but I can not get them to work on the iPad. http://kraner.se/customers/test.html

I would like a working permit for this. Is anyone

+5
1

javascript ( ):

        $(document).ready(function() {
        //Select text on focus for input
        $("input:text").focus(focustext);
    });
    function focustext() {
        var input = this;
        setTimeout(function () {
            input.selectionStart = 0;
            input.selectionEnd = input.val().length;
        },100);
    }

. = , , .

iOS6 iOS7, Chrome IE Windows 7. IE .

+3

All Articles