Selecting text on focus using jQuery not working in Safari and Chrome

前端 未结 9 1800
耶瑟儿~
耶瑟儿~ 2020-11-28 20:45

I have the following jQuery code (similar to this question) that works in Firefox and IE, but fails (no errors, just doesn\'t work) in Chrome and Safari. Any ideas for a wo

9条回答
  •  广开言路
    2020-11-28 21:23

    This should work also in chrome:

    $("#souper_fancy").focus(function() {
        var tempSouper = $(this);
        setTimeout(function(){
            tempSouper.select();
        },100);
    });
    

提交回复
热议问题