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

前端 未结 6 671
心在旅途
心在旅途 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:59

    You could try triggering a right key press after focus.

    $('#textbox').focus();
    var e = jQuery.Event("keydown");
    e.which = 39; // aka right arrow.
    $("input").trigger(e);
    

提交回复
热议问题