[英]Css background image not getting set
我正在尝试使用设置背景图像
document.body.style.backgroundImage = "theurltothebackground";
但它一直给我一个错误说
未捕获的类型错误:无法在(索引):11(匿名)@(索引):11 处读取 null 的属性“样式”
我已经检查并仔细检查了代码,我很困惑为什么它给了我那个错误。 请帮我
答:感谢isherwood ,我在body元素之前有脚本
你需要使用我想象的背景和“url('url')”
document.body.style.backgroundImage = "url('image.png')";
使用 背景图片
document.body.style.backgroundImage = "theurltothebackground";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.