IcyBright
IcyBright

Reputation: 664

set the curser to the beginning of textarea using jquery

MyEvent.prototype.sendMessage_ = function(input) {
  //input is this.find('#mytextarea');
  if (input.val().trim() != '') {
    input.val('');
    $('#mytextarea').focus();
  }
};

//...in the html....//
<textarea type="text" placeholder="Input Here" id="mytextarea"></textarea>

After empty a textarea with Jquery, the cursor is still at the end of the input, how could one move the cursor to the beginning of the textarea?

And in the view I have:

Upvotes: 0

Views: 56

Answers (2)

Jameem
Jameem

Reputation: 1838

Try this..

$('#mytextarea')[0].focus();

Upvotes: 0

Mike
Mike

Reputation: 211

Try using $('#mytextarea').focus()

Upvotes: 1

Related Questions