Reputation: 8578
I would like to focus cursor in place of as I want. Can it be possible with html or css or javascript ? I have a simple textarea as
<textarea name="contents" cols="100" rows="50"></textarea>
Now I can only focus cursor and type from top-left cornor of my textarea. But I want to focus and start type in the middle of textarea. How can I figure it out ?
Now I am using with Enter keys and Space keys of my keboard to place my cursor.
I want to type without using enter keys and space keys:
Upvotes: 0
Views: 347
Reputation: 4038
It can be a way to fill your textarea
with spaces and then you can type wherever you clicked on.
jQuery :
var $contentTextarea = $("textarea[name='contents']");
var cols = Number($contentTextarea.attr("cols"));
var rows = Number($contentTextarea.attr("rows"));
for(var i = 0; i < cols; i++){
for(var j = 0; j < rows; j++ ){
$contentTextarea.append(" ");
}
$contentTextarea.append("\n");
}
Upvotes: 1