Possible to scroll caret into view inside a single HTML text field with JavaScript?

前端 未结 6 649
心在旅途
心在旅途 2021-02-04 03:41

Knowing the jQuery Caret plugin, I\'m still seeing no way to do the following on a single line text box in HTML (i.e. the input:type=text control) with JavaScript:<

6条回答
  •  有刺的猬
    2021-02-04 03:50

    try to set the scrollLeft property of the input, as:

    input.scrollLeft = 10000;
    

    You can use scrollWidth to get a better guess on the final value, but using a high one can ensure correctness on most cases.

提交回复
热议问题