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

前端 未结 6 666
心在旅途
心在旅途 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 04:00

    //hack to get cursor at end:

    $(textboxselector).val($(textboxselector).val());
    

    edit: should note focus first:

    $(textboxselector).val(newtext);
    $(textboxselector).focus();
    $(textboxselector).val($(textboxselector).val());
    

提交回复
热议问题