怎麼用js腳本,選中文本呢?spa
// 獲取selection對象 var selection = window.getSelection(); // 清空selection對象 selection.removeAllRanges(); // 建立一個Range實例 var ele = document.getElementById('blogTitle') var range = new Range(); range.selectNodeContents(ele); // selection對象設置range實例 selection.addRange(range);