Select all text in textarea jquery

How to make all text in textarea selected when user open it through jquery?

Answers


$('textarea').on('mouseup', function() { $(this)[0].select(); });‚Äč

http://jsfiddle.net/Tu9N7/


Input.select

var eraInput = document.getElementById('era');
eraInput.select();

$('textarea').focus(function() {
  this.select();
})

DEMO

From the line "when user open it through jquery" I think you need something like:
$('textarea').slideDown(function() {
    $(this).focus();
}).focus(function() {
    this.select();
});

Here I assume your textarea is hidden and you opened it using jQuery event and after open it text will be selected by default.

DEMO


Need Your Help

$_POST the javascript Date() time at the time of submit button clicked

php javascript html post

I am currently coding a web page that allows users to change local settings on a singleboard embedded computer. A feature I am currently working on involves syncing the clock on the board with the ...