当前位置: 代码迷 >> JavaScript >> js控制readonly有关问题
  详细解决方案

js控制readonly有关问题

热度:212   发布时间:2012-08-21 13:00:22.0
js控制readonly问题
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <title> New Document </title>
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
</head>
<script language="JavaScript">
function isreadonly(){
var obj = document.getElementById("username");
obj.setAttribute("readOnly",true);
}
function readwrite(){
var obj = document.getElementById("username");
obj.setAttribute("readOnly",false);
}
</script>
<body>
  <form name="addform" id="addform" method="post" action="">
  <input type="text" id="username" name="username" >
  <input type="button" name="只读" value="只读" onclick="isreadonly();">
  <input type="button" name="可写" value="可写" onclick="readwrite();">
  </form>
</body>
</html>
  相关解决方案