日期:2014-05-16 浏览次数:20454 次
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript"> function change() { document.bgColor = "red"; } </script> </head> <body> <input type="text" name="color" id="color"/> <input type="button" onclick="change(color)"/> </body> </html>
<html> <head> </head> <body> <input type="text" name="color" id="color"/> <input type="button" onclick="change()" value="确定"/> </body> <script> function change(){ var color_key=document.getElementById("color").value; document.body.style.backgroundColor=color_key; } </script> </html>
------解决方案--------------------
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript"> function change() { var color = document.getElementById("color").value; document.bgColor = color; } </script> </head> <body> <input type="text" name="color" id="color"/> <input type="button" onclick="change()"/> </body> </html>