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
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With