function box(){ document.getElementById("click").style.WebkitTransform="scale(1.2)"; } function jiao(){ document.getElementById("click").style.WebkitTransform="scale(1)"; }
我们来点击运行测试一下:
<!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> <title> new document </title> <meta name="generator" content="editplus" charset="utf-8" /> <meta name="author" content="" /> <meta name="keywords" content="" /> <meta name="description" content="" /> </head> <style type="text/css"> .box{ margin:30px 0 0 30px; 100px; background-color:green; color:white; text-align:center; cursor:pointer; padding:30px; } </style> <script type="text/javascript"> function box(){ document.getElementById("click").style.WebkitTransform="scale(1.2)"; } function jiao(){ document.getElementById("click").style.WebkitTransform="scale(1)"; } </script> <body> <div class="box" id="click" onMouseOver="box()" onMouseOut="jiao()"> 点我! </div> </body> </html>