1 <html> 2 <head> 3 <title>textarea显示为label</title> 4 <style type="text/css"> 5 .textdisplay { 6 background-color:#eeeeee; 7 border-bottom-style:none; 8 border-left-style:none; 9 border-right-style:none; 10 border-top-style:none; 11 font-size:14px; 12 } 13 </style> 14 <script language="javascript"> 15 function setTxt(obj){ 16 if(obj=='e'){ 17 document.getElementById('sendcontent').className=''; 18 document.getElementById('sendcontent').readOnly=false; 19 document.getElementById('save').disabled=false; 20 document.getElementById('cancel').disabled=false; 21 } 22 if(obj=='c'){ 23 document.getElementById('sendcontent').className='textdisplay'; 24 document.getElementById('sendcontent').readOnly=true; 25 document.getElementById('save').disabled=true; 26 document.getElementById('cancel').disabled=true; 27 } 28 } 29 30 </script> 31 </head> 32 33 <body> 34 35 <textarea class="textdisplay" cols="" rows="" id="sendcontent" name="sendcontent" style="height:500px;600px;" readonly> 36 <input type="submit" disabled=true id="save" name="save" value="保存" style="height:24px;vertical-align:middle;line-height:20px;" /> 37 <input type="button" name="edit" value="编辑" style="height:24px; vertical-align:middle;line-height:20px;" onclick="setTxt('e')" /> 38 <input type="button" disabled=true id="cancel" name="cancel" value="取消" style="height:24px; vertical-align:middle;line-height:20px;" onclick="setTxt('c')" /> 39 </body> 40 </html>