700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > js监听只读文本框_js设置input文本框只读

js监听只读文本框_js设置input文本框只读

时间:2020-08-08 01:18:23

相关推荐

js监听只读文本框_js设置input文本框只读

控制input框只读可以防止用户对数据的更改,在某些情况下还是比较实用的,下面使用js来完成这个只读实现

New Document

content="">

name="Description" content="">

function isreadonly(){

var obj =

document.getElementById("username");

obj.setAttribute("readOnly",true);

obj.style.backgroundColor="#d2d2d2";

}

function readwrite(){

var

obj = document.getElementById("username");

obj.setAttribute("readOnly",false);

obj.style.backgroundColor="#ffffff";

}

id="addform" method="post" action="" >

id="username" name="username">

value="read" οnclick="isreadonly();">

value="write" οnclick="readwrite();">

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。