Adding readonly attribute to all form elements

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 *.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)