Try this:
$('#form1 input').attr('readonly', 'readonly');
- You may want to include more elements
#form1 input, #form1 textarea, #form1 select - In jQuery, you usually don’t need to iterate over the collection.
attrwould work for a collection same as for a single element. - In your case,
#form1matched just the<form>element, andeachwas triggered once, for that element. To find all elements (input or not), you can write#form1 *.