我在这里读到我可以使用以下方法定位我的 div 背景图像:
var yValue = 20;
document.getElementById('a1').style.backgroundPosition = '0px ' + yValue + 'px';
但是我将如何为body background-position使用 JavaScript 执行此操作,主体id = 'bodyname'是否为getElementById()函数参数提供了一个?
<!DOCTYPE html>
<html>
<head>
<style>
body
{
background-image: url('image.gif');
background-repeat: repeat;
background-attachment:fixed;
background-position: 77px 100px;
}
</style>
</head>
<body>
</body>
</html>