js控制input框只读实现示例


<html>
<head>
<title> New Document </title>
<meta content="EditPlus">
<meta content="">
<meta content="">
<meta content="">
</head>
<script language="JavaScript">
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";
}
</script>
<body>
<form method="post" action="" >
<input type="text">
<input type="button" value="read">
<input type="button" value="write">
</form>
</body>
</html>
<!--
点击“read”按钮,input框不能书写,且变灰;点击“write”按钮,input框恢复。
-->

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdypsy.html