以下内容分为html(含js),css;
1.html(含js,jquery,bootsratp):
jquery自己下jquery-3.3.1.min.js
bootstrap通过联网用
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="../css_pro/degree.css" type="text/css"/>
<script type="text/javascript" src="../jquery-3.3.1.min.js" ></script>
<script>
function changecolor(e)
{
for(var i=1;i<=5;i++)
{
if(i<=e)
{
var a="#star"+i;
//console.log("a="+a);
$(a).css("color","red");
}
else{
var a="#star"+i;
//console.log("a="+a);
$(a).css("color","black");
}
}
}
</script>
</head>
<body>
<span class="glyphicon glyphicon-star"id="star1"onclick="changecolor(1)"></span>
<span class="glyphicon glyphicon-star"id="star2"onclick="changecolor(2)"></span>
<span class="glyphicon glyphicon-star"id="star3"onclick="changecolor(3)"></span>
<span class="glyphicon glyphicon-star"id="star4"onclick="changecolor(4)"></span>
<span class="glyphicon glyphicon-star"id="star5"onclick="changecolor(5)"></span>
</body>
</html>
2.css:
#star1,#star2,#star3,#star4,#star5
{
width:30px;
heiht:30px;
font-size: 30px;
}