在这里,我正在尝试制作一个类似 facebook 的按钮。这是我的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>like button</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<style>
#like {
height: 215px;
background: url(images/sprite.png) no-repeat;
background-position: 0px 0px;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("#like").click(function(){
$("#like").css("background-position","0px -225px");
});
});
</script>
</head>
<body>
<div id="like">
</div>
</body>
</html>
现在,当用户单击该图片时,该图片将发生变化。我想反过来改变那张照片。我怎样才能?有没有其他完美的方法来实现这个?