1、js為設定readOnly屬性 var cObj = document.getElementById("content"); cObj.setAttribute("readOnly",'true'); 2、js移除readOnly屬性 var cObj = document.getElementById("content"); cObj.removeAttribute("readOnly"); 注意:一定要注意readOnly大小寫! ! !