鍍金池/ 問(wèn)答/HTML5  HTML/ Javascript 設(shè)置背景圖片問(wèn)題

Javascript 設(shè)置背景圖片問(wèn)題

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<script type="text/javascript">

    var picUrl = "http://cn.bing.com/az/hprichbg/rb/ToroidalBubble_ZH-CN10711997835_1920x1080.jpg";

    document.body.style.background = "url('picUrl')";

</script>
</body>
</html>

圖片描述

回答
編輯回答
咕嚕嚕

你腳本是不是放在head里面的

2017年12月4日 16:27
編輯回答
茍活

語(yǔ)法錯(cuò)誤:

document.body.style.background = "url("+picUrl+")";
2018年5月10日 10:16