效果图 <input type="text" name="" id="input" value="选择区域" onclick="fn()"/> var inputs = document.getElementById("input"); function fn(){ var text = "新增" console.log("选中区域左边界:" + inputs.selectionStart) console.log("选中区域右边界:" + inputs.selectionEnd) }