必须先获取input框焦点才能选中文本 html <input type="text" id="text" name="" value="hello world!"> js版本 document.getElementById("text").focus(); document.getElementById("text").select(); jq版本 $('#text').focus(); $('#text').select();