textarea 在 DOM 中的游標操作較為繁瑣,封裝後能明顯提升開發效率。
舊版 IE 使用 document.selection 與 TextRange,現代瀏覽器則使用 selectionStart、selectionEnd 與 setSelectionRange。Firefox 在重設 value 後可能重置捲動位置,可用 setTimeout 還原 scrollTop。