This is a textarea
,
<textarea placeholder="what's new..." id="messageID" type="text" ng-model="content"></textarea>
Please how can I trigger insertion point or cursor on this textarea
.
This is a textarea
,
<textarea placeholder="what's new..." id="messageID" type="text" ng-model="content"></textarea>
Please how can I trigger insertion point or cursor on this textarea
.
<body OnLoad="document.myform.mytextfield.focus();">
<form name="myform">
<textarea name="mytextfield" placeholder="what's new..." id="messageID" type="text" ng-model="content"></textarea>
</form>
</body>
function setSelection(id, start, end) {
var input = document.getElementById(id);
input.focus();
input.setSelectionRange(start, end);
}
with this function you can set the selection begining and end in number of characters from the start of the string (eg. setSelection('messageID', 0, 10) would select the first 10 characters.
If you are using angular you should use other methods to access the DOM input element, bu the setSelectionRange call would be the same.