Noonf,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
.rating {
list-style: none;
padding: 0px;
margin: 0px;
cursor: default;
font-size: 0px;
user-select: none;
display: inline-block;
position: relative;
}
.rating:after {
font-size: 36px;
top: 4px;
left: 100%;
content: attr(text);
color: #FF0000;
display: block;
position: absolute;
margin-left: 12px;
}
.rating > li {
display: inline-block;
font-size: 36px;
cursor: pointer;
}
.rating > li::before {
content: "★"
}
.stars a.active,
.rating > li.active,
.rating:hover > li {
color: orange;
}
.rating:hover > li:hover ~ li{
color: #000000;
}
.stars a{
font-size: 36px;
cursor: pointer;
}
</style>
<script>
window.addEventListener('DOMContentLoaded', function() {
[].forEach.call(document.querySelectorAll('.rating, .stars span'), function(item) {
item.addEventListener('click', function(event) {
event.preventDefault();
var method = "add", elem = event.target;
[].forEach.call( item.children, function(el, i) {
el.classList[method]('active');
if(el == elem) {
method = "remove";
item.setAttribute("text", ++i)
}
});
});
});
});
</script>
</head>
<body>
<ul class="rating" >
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul> <br>
<p class="stars">
<span >
<a class="star-1">★</a>
<a class="star-2">★</a>
<a class="star-3">★</a>
<a class="star-4">★</a>
<a class="star-5">★</a>
</span>
</p>
</body>
</html>