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.
attr
would work for a collection same as for a single element.
- In your case,
#form1
matched just the <form>
element, and each
was triggered once, for that element. To find all elements (input or not), you can write #form1 *
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…