0

I'm trying to change attribute of a textarea on focus, but it's not working.

HTML:

<textarea name='naziv' id='name'>Naziv</textarea> 

Jquery:

$('textarea#name').focus(function(){ $(this).attr('readonly','readonly');}); 

JsFiddle

2
  • You need to add jQuery as well. Commented Sep 12, 2013 at 22:43
  • And you should be using prop('readonly', true); Commented Sep 12, 2013 at 22:44

1 Answer 1

1

Actually, your code works. In jsFiddle you forgot to tick off the jQuery library.

Under Frameworks & Extensions, choose a jQuery version. 

Fixed jsFiddle

Sign up to request clarification or add additional context in comments.

1 Comment

Well, this is embarrassing.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.