我的代码:
<html>
<head>
<script type="text/javascript" charset="utf-8">
function backgroundImage() {
document.body.style.backgroundImage='url("http://www.image.jpg")';
}
</script>
</head>
<body onLoad="backgroundImage()">
Content here
</body>
</html>
但是添加了document.ready:
$(document).ready(function () {
document.body.style.backgroundImage='url("http://www.image.jpg")';
});
破坏代码
为什么这不起作用,我缺少什么,或者不需要 document.ready 的前缀?难道‘document’不应该被调用两次吗?
提前致谢!
亲切的问候, 戴尔
最佳答案
这没问题,可以运行
关于JavaScript 背景图像被 $(document).ready 破坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8640884/