<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title>笑脸评价</title>
<script src="../js/jquery-3.2.1.min.js"></script>
<style>
.smile_bad,.smile_med,.smile_good{
width: 0.3rem;
height: 0.3rem;
background-repeat: no-repeat;
display: inline-block;
}
.smile_bad{
background-image:url("../img/bad_normal.png");
background-size: 0.3rem;
}
.smile_med{
background-image:url("../img/med.png");
background-size: 0.3rem;
}
.smile_good{
background-image:url("../img/good_normal.png");
background-size: 0.3rem;
}
.bad_active{
background-image:url("../img/bad-active@3x.png");
background-size: 0.3rem;
}
.med_active{
background-image:url("../img/med-active@3x.png");
background-size: 0.3rem;
}
.good_active{
background-image:url("../img/good-active@3x.png");
background-size: 0.3rem;
}
</style>
</head>
<body>
<div class="smile_images">
<span class="smile_bad"> </span>
<span class="smile_med"></span>
<span class="smile_good"></span>
</div>
</body>
<script>
$(function(){
$(".smile_bad").click(function(){
$(".smile_bad").toggleClass('bad_active');
});
$(".smile_med").click(function(){
$(".smile_med").toggleClass('med_active');
});
$(".smile_good").click(function(){
$(".smile_good").toggleClass('good_active');
});
})
</script>
</html>
点击来回切换图片