<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www./1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>通过style改变局部的样式</title> <script type="text/javascript"> function red(){ //backgroundColor中的color要大写 document.getElementById("button").style.height="200px" document.getElementById("button").style.backgroundColor="red" } </script> </head>
<body> <input id="button" type="button" value="点击改变" onclick="red()"/> </body> </html>
|