这里的HTML如何更改使用javascript的网站上的背景图像位置?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<script type="text/javascript" src="temp.js">
</script>
<style type="text/css">
body {
background-image: url(image.jpg);
background-repeat: no-repeat;
background-position: 0px 100px;
}
</style>
<body>
<p>This is a test paragraph to fill space</p>
<input type="button" onClick="size()"/>
</body>
</html>
和JavaScript
function size() {
var body = document.getElementsByTagName("body");
body.style.backgroundPosition: "0px 30px";
}
但由于某些原因,当我按一下按钮没有任何反应。任何人都知道什么不起作用?
这是简单的使用只是'document.body'来指代'body'元素。 –
@ JukkaK.Korpela:谢谢!更新。 –