JSFiddle - React, Tailwind, and code Playground
HTML
<textarea id=editor>
This is a bunch of text
that takes up a bunch of
lines so it has to scroll
This is a bunch of text
that takes up a bunch of
lines so it has to scroll
This is a bunch of text
that takes up a bunch of
lines so it has to scroll
This is a bunch of text
that takes up a bunch of
lines so it has to scroll
</textarea>
<input id='move' type='button' value='move down'></input>
CSS
textarea {
height: 60px;
width: 250px;
scroll-Y: scroll;
scroll-X: none;
resize: none;
}
JavaScript
var cursorPos = 0;
$('#move').click(function () {
cursorPos += 10;
$('#editor')[0].selectionStart = cursorPos;
$('#editor')[0].selectionEnd = cursorPos;
});