Home >Web Front-end >JS Tutorial >Javascript: Set the readOnly attribute for input (example explanation)_javascript skills
1. js sets the readOnly attribute for
var cObj = document.getElementById("content");
cObj.setAttribute("readOnly",'true');
2. js removes readOnly attribute
var cObj = document.getElementById("content");
cObj.removeAttribute("readOnly");
Note: Be sure to pay attention to the capitalization of readOnly! ! !