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

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

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

  2020-05-13 我要评论

1、js为<input>设置readOnly属性

      <textarea name="content" id="content" cols="27" rows="6"></textarea>

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

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


2、js移除<input>readOnly属性

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

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

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们