Select the Textarea button using the button

I want to select the textarea field when the user clicks a button. My code is:

<textarea readonly="readonly"> </textarea> <input type="button" value="Code"/>

Jquery Code:

 $(function() {

      $(input:button').click(function(){
    ('textarea').select();
  });
});

Does not work.

+3
source share
1 answer

Do you mean:

$("input[type='button']").click(function(){
    $('textarea').focus();
    $('textarea').select(); //select text inside
});
+6
source

All Articles