欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

Javascript:为input设置readOnly属性(示例讲解)_javascript技巧

程序员文章站 2022-05-14 21:34:05
...
1、js为设置readOnly属性

var cObj = document.getElementById("content");

cObj.setAttribute("readOnly",'true');


2、js移除readOnly属性

var cObj = document.getElementById("content");
cObj.removeAttribute("readOnly");

注意:一定要注意readOnly大小写!!!