John
John

Reputation: 159

Select the Textarea using Button

I want to select the textarea field when user click on button. My Code:

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

Jquery Code:

 $(function() {

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

It's not working.

Upvotes: 3

Views: 1460

Answers (1)

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100175

Do you mean:

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

Upvotes: 6

Related Questions