|
如何更换textarea的背景色及背景图片
以下是HTML网页特效代码,点击运行按钮可查看效果: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>textarea换背景最“偷懒”的方法。</title> <style type="text/css"> /*onfocus onblur*/ .textareaOn{ padding:5px; width:350px; height:150px; background:#FFFFCC; border:1px solid #F90; } .textareaOut{ padding:5px; width:350px; height:150px; border:1px solid #CCC; } </style> </head> <body> <textarea id="textarea01" class="textareaOut" name="d" cols="" rows="" ></textarea> <script type="text/javascript"> var textarea01 = document.getElementById("textarea01"); textarea01.onfocus = function(){ this.className = "textareaOn"; } textarea01.onblur = function(){ this.className = "textareaOut"; } </script> </body> </html>
|