1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 5 <title>无标题文档</title> 6 <style> 7 #div{width:100px;height:200px;border:2px solid red;background:blue;} 8 </style> 9 <script> 10 window.οnlοad=function(){ 11 var style1=document.getElementById('style1'); 12 var shu=document.getElementById('shu'); 13 var button1=document.getElementById('button1'); 14 15 button1.οnclick=function(){ 16 div.style[style1.value]=shu.value; 17 }; 18 }; 19 </script> 20 </head> 21 <body> 22 请输入样式:<input id="style1" type="text" value=""/><br/> 23 请输入数据:<input id="shu" type="text" value=""/> 24 <input id="button1" type="button" value="button"/> 25 <div id="div"></div> 26 27 </body> 28 29 30 31 32 33 </html>