js获取文本宽度 js获取input所在光标的文字位置

https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript/21015393#21015393

 

https://stackoverflow.com/questions/2897155/get-cursor-position-in-characters-within-a-text-input-field/48150864#48150864

 

 

通过这两个可以计算出input文字所选择的位置的宽度

posted @ 2020-10-19 15:15  hh9515  阅读(416)  评论(0)    收藏  举报