在HTML中,可以使用readonly属性来设置文本框只读。例如:
<input type="text" readonly="readonly" value="只读文本框">
在JavaScript中,可以通过修改元素的readOnly属性来设置文本框只读。例如:
var input = document.getElementById("myInput");
input.readOnly = true;
这将使id为“myInput”的文本框变为只读。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:html文本框只读属性怎么设置