Setting cursor at end of added text to Textarea

I'm using a textarea as a sort of log console in a page, which receives data to be added at the end of the current text. When i add more text to the textarea, how can i make it so it scrolls down as new text is added?



  • Hi,

    You need to work with the Textarea's input node to manipulate scroll position and cursor:

    var log = $$("log");
    var pos = log.getValue().length;
    var height = log.getInputNode().scrollHeight;
    //set cursor in the end
    webix.html.setSelectionRange(log.getInputNode(), pos);
    //show the input end
    $$("log").getInputNode().scrollTop = height;

    Check the following snippet, please:

  • Sorry,I did as you said but I have this error: Uncaught RangeError: Maximum call stack size exceeded.

  • Hello,

    I've checked the snippet in my environment and everything is working smoothly. Could you please provide the exact snippet of your implementation and share the OS/browser in use?

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!