2
可能重複:
how can i get cursor position in a textarea?有沒有一個JavaScript庫可以幫助我操作textarea?
我想與JavaScript的textarea的一些基本的,但常見的操作,如
- 得到光標位置
- 設置光標
- 插入一些文本光標位置
- 選擇textarea的
- 所有文字選擇一個文本範圍
- 的插入一些文本光標位置,並立即將其選中。
我希望它能夠跨瀏覽器工作。
有沒有這樣的JavaScript庫?
看看這個http://stackoverflow.com/questions/1891444/how-can-i-get-cursor-position-in-a-textarea/1909997#1909997 – Craig 2011-05-13 17:00:09
或者:http:// code。 google.com/p/rangy/。 – pimvdb 2011-05-13 19:29:34
@pimvdb,'rangy'功能強大,但它太大了(壓縮後39K)。 – Freewind 2011-05-14 01:55:25