0
我有五颗星,当鼠标悬停在鼠标悬停的星星和该星星之前的星星必须改变为不同的颜色。 onclick事件也一样。以下是HTML代码。我已经尝试了一些CSS。但我不明白该怎么做?如何获取CSS代码?CSS为5星级评分系统
<script type="text/javascript">
$(document).ready(function(){
$("#images img").click(function(){
$(this).addClass('active');
var va = $(this).attr("name");
$("#result_value").text(va);
});
$("#images img").mouseover(function(){
});
});
$(document).on('click','#images img',function(e) {
var va = $(this).attr("name");
$.ajax({
data:' va='+va,
type: "post",
url: "insertmail.php",
success: function(va){
alert("Data Save: " + va);
}
});
});
</script>
<style>
.clr:hover{
background-color:#FFD700;
}
.active{
background-color:#FFD700;
}
</style>
</head>
<body>
<div class="images" id="images">
<form name="imagediv" id="imagediv" method="post">
<img src="star1.png" class="one clr" alt="Number 1" name="1" width="42" height="42">
<img src="star2.png" class="two clr" alt="Number 1" name="2" width="42" height="42">
<img src="star3.png" class="three clr" alt="Number 1" name="3" width="42" height="42">
<img src="star4.png" class="four clr" alt="Number 1" name="4" width="42" height="42">
<img src="star5.png" class="five clr" alt="Number 1" name="5" width="42" height="42">
</form>
</div>
<div class="result_value" id="result_value" ></div>
</body>
如果您计划使用图像。尝试使用图像精灵。 http://css-tricks.com/css-sprites-with-inline-images/ – Blunderfest