In newer jQuery (1.6+):
$('div input').prop("readonly", true);
This sets the HTML readonly
property to true for all inputs in a div.
Please note that using .attr()
to set properties (attributes with boolean values of on or off) has been deprecated in jQuery.