什么是 Vanilla JS 或 jQuery 解决方案,它会在文本框获得焦点时选择文本框的所有内容?
获得焦点时选择文本框的所有内容(Vanilla JS 或 jQuery)
IT技术
javascript
jquery
user-interface
                    2021-01-30 17:30:49
                
                    
                
            
        6个回答
            $(document).ready(function() {
    $("input:text").focus(function() { $(this).select(); } );
});
<input type="text" onfocus="this.select();" onmouseup="return false;" value="test" />
$(document).ready(function() {
  $("input[type=text]").focus().select();
});
$(document).ready(function() {
    $("input:text")
        .focus(function () { $(this).select(); } )
        .mouseup(function (e) {e.preventDefault(); });
});
其它你可能感兴趣的问题