頁面有大量 <input>,需批次移除文字框的唯讀屬性,保留按鈕等其他類型。
$("input[type=text]").prop("readOnly", false);
input[type=text] 精確匹配文字輸入框。.prop() 而非 .attr(),因 readOnly 是 DOM 屬性,jQuery 1.6+ 建議用 prop。textarea:$("input[type=text], textarea").prop("readOnly", false);document.querySelectorAll('input[type=text]').forEach(el => el.readOnly = false);