Reputation: 2915
How to make all text in textarea selected when user open it through jquery?
Upvotes: 3
Views: 5613
Reputation: 87073
$('textarea').focus(function() {
this.select();
})
$('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.
Upvotes: 0
Reputation: 207557
var eraInput = document.getElementById('era');
eraInput.select();
Upvotes: 1