首页 > 代码库 > 变背景图片位置

变背景图片位置

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type ="text/javascript">
function changeTab(obj) {
var tabsDiv = document.getElementById("tabs");
var links = tabsDiv.getElementsByTagName("a");
for (var i = 0; i < links.length; i++) {
if (obj==links[i]) {
links[i].style.backgroundPosition = "0px -32px";
} else {
links[i].style.backgroundPosition = "0px 0px";
}
}
}
</script>
</head>
<body>
<div id="tabs">
<a href ="http://www.mamicode.com/#" onclick ="changeTab(this);return false;">谷歌</a>
<a href ="http://www.mamicode.com/#" onclick ="changeTab(this);return false;">百度</a>
<a href ="http://www.mamicode.com/#" onclick ="changeTab(this);return false;">学习</a>
<a href ="http://www.mamicode.com/#" onclick ="changeTab(this);return false;">视频</a>
<a href ="http://www.mamicode.com/#" onclick ="changeTab(this);return false;">百科</a>
</div>
</body>
</html>

变背景图片位置