JavaScript 参考手册
Style background 属性
设置文档背景的样式
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>蜜蜂教程(mifengjc.com)</title> <script> function displayResult() { document.body.style.background = "#f3f3f3 url(" / examples / img_tree.png ") no-repeat right top"; } </script> </head> <body> <h1>Hello World!</h1> <br> <button type="button" onclick="displayResult()">设置背景</button> </body> </html>
运行结果:
点击运行 »