How js achieves star scoring _ javascript skills

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.