How to make all text in textarea selected when user open it through jquery?
3 Answers
$('textarea').on('mouseup', function() { $(this)[0].select(); }); Comments
var eraInput = document.getElementById('era'); eraInput.select(); 1 Comment
brasofilo
Wow, great stuff here, jQ didn't do the job, this one did.
$('textarea').focus(function() { this.select(); }) 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.