Copy codeThe Code is as follows:
<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 );
Obj. style. backgroundColor = "# d2d2d2 ";
}
Function readwrite (){
Var obj = document. getElementById ("username ");
Obj. setAttribute ("readOnly", false );
Obj. style. backgroundColor = "# ffffff ";
}
</Script>
<Body>
<Form name = "addform" id = "addform" method = "post" action = "">
<Input type = "text" id = "username" name = "username">
<Input type = "button" name = "read-only" value = "read" onclick = "isreadonly ();">
<Input type = "button" name = "writable" value = "write" onclick = "readwrite ();">
</Form>
</Body>
</Html>
<! --
Click the "read" button. The input box cannot be written and becomes grayed out. Click the "write" button and restore the input box.
-->