tags:

views:

106

answers:

3

For text input I do:

$('input[type="text"]').each(function(){
  $(this).attr('readonly','readonly');
});

But what should I do for textarea, to make it readonly.

+5  A: 

Include it in your selector (using a multiple/element selector), like this:

$('input[type="text"], textarea').attr('readonly','readonly');

You can test it here, if it's the only thing you're doing, there's no need for a .each(), you can just call .attr() on all matched elements.

Nick Craver
That worked ..thanks a lot...
pradeep
A: 

Try this

$("#mytxtarea").attr("disabled", "disabled");
Gopi