This article mainly introduces how js achieves the star scoring effect. it involves javascript operations on page elements and styles and is very useful, for more information about how to use js to score stars, see the following example. Share it with you for your reference. The specific analysis is as follows:
Many websites have such a star scoring effect. Today, we will look at how js can be used to achieve the scoring effect.
Detailed results
1. when the mouse moves up, the stars light up and the text below is displayed. When the mouse moves out, the stars are gray and the text below is not displayed.
2. move the mouse over a star, and all the stars before it will be bright.
3. move the cursor over a star and click it. the score is displayed.
The code is as follows:
Switch Script window. onload = function () {var star = document. getElementById ("star"); var star_li = star. getElementsByTagName ("li"); var star_word = document. getElementById ("star_word"); var result = document. getElementById ("result"); var I = 0; var j = 0; var len = star_li.length; var word = ['Bad ', 'Bad', 'average ', "Good", "good"] for (I = 0; I
Score result
Average
I hope this article will help you design javascript programs.