<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css">
ul{
width: 150px;
height: 30px;
}
li{
list-style: none;
width: 27px;
height: 28px;
float: left;
background: url(images/star.gif);
}
</style>
<script type="text/javascript">
window.onload=function () {
var lis= document.getElementsByTagName("li");
for (var i = 0; i < lis.length; i++) {
lis[i].currentIndex=i;
lis[i].onmouseover = function (e) {
var event = e || window.event;
var li = event.target|| event.srcElement;
changeColor(li.currentIndex);
};
}
function changeColor(index) {
for (var j = 0; j < lis.length; j++) {
lis[j].style.background = "url(images/star.gif)";
}
for (var i = 0; i <= index; i++) {
lis[i].style.background = "url(images/star.gif) 0 -29px";
}
}
}
</script>
</head>
<body>
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</body>
</html>