阅读背景:

使用js设置input标签只读 readonly 属性_weixin_30881367的博客

来源:互联网 

先上代码:

 
<html>

<head>
    <title> test </title>
    <meta charset="utf-8">
</head>
<script language="JavaScript">
    function setReadonly() {
        //document.getElementById("test").setAttribute("readOnly", true);
        document.getElementById("test").readOnly=true;
    }

    function readWrite() {
        //document.getElementById("test").setAttribute("readOnly", false);
        document.getElementById("test").readOnly=false;
    }
    
</script>

<body>
    <form name="addform" id="addform" method="post" action="">
        <input type="text" id="test" >
        <input type="button"  value="只读" οnclick="setReadonly();">
        <input type="button"  value="读写" οnclick="readWrite();">
    </form>
</body>

</html><html>

<hea



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: