通过属性如何设置文本框为只读

2025-04-18 17:53:13

1、文本框标签格式<input type="text" />;

通过属性如何设置文本框为只读

2、设置文本框为只读属性readonly="readonly";

通过属性如何设置文本框为只读

3、最终方式:<input type="text" readonly="readonly"/>;

通过属性如何设置文本框为只读

4、<input type="text" name="username" id="username"/><script type="text/javascript">

通过属性如何设置文本框为只读

5、document.getElementById("username").readOnly租涫疼迟="readonly";只读document.getElementById("username").readOnly="";可读

通过属性如何设置文本框为只读

6、document.getElementById("username").disabled租涫疼迟="disabled";失效document.getElementById("username").disabled="";有效</script>

通过属性如何设置文本框为只读

7、当然你在页面如果引入了js文件,那么$("#username").readOnly="readonly";也是可以实现相同的效果的,上面只是贴出了主要的部分代码,有兴趣的可以试试,谢谢支持

通过属性如何设置文本框为只读
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢