JS点击2
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 <style type="text/css"> 7 #div1{ 8 width: 200px; 9 height: 200px; 10 border: 1px solid black; 11 } 12 </style> 13 <script type="text/javascript"> 14 function toChange(name, value){ 15 var a=document.getElementById("div1"); 16 a.style[name]=value; 17 } 18 </script> 19 </head> 20 <body> 21 <input type="button" value="变蓝" onclick="toChange('background', 'blue')" /> 22 <input type="button" value="变高" onclick="toChange('height', '300px')"/> 23 <input type="button" value="变宽" onclick="toChange('width', '300px')"/> 24 <div id="div1"></div> 25 </body> 26 </html>