Native JS implementation-simple example of star rating system and js Rating System

Source: Internet
Author: User

Native JS implementation-simple example of star rating system and js Rating System

Today, I wrote another cool example: star rating system (you can customize the number of stars and display information)
SufuStar. star ();
Use the default value of 5 stars, default information

Var msg = [...];
SufuStar. star (10, msg );

The number of custom stars is 10. For information displayed in msg Format, refer to the default value. The number of entries must be consistent with the number of stars;

You can implement some instances on your own, which has the advantage of increasing the proficiency of each knowledge point in the application and checking your weak items! Once discovered, immediately turn over the API documentation!

I don't know if I am too stupid. This instance has been written for a whole day!

No nonsense. Let's talk about the knowledge points involved in this instance:

1. Use the border of CSS to draw a triangle and use before to add it to other elements;

2. Learn how to use CSS to locate elements;

3. Learn the event proxy;

4. How to optimize performance;

5. Application of the match Method of the String object and the application of the regular expression;

6. Registration of events and event handling requires compatibility with IE writing;

7. Learn how to use '|' to set the default value for the variable;

8. Simplified code: take out the code that may be repeated and write it as a function separately;

The following is the complete code with annotations. If you don't understand it, check the document. At my current level, you can only write it like this. If you have any good suggestions, please let us know!

<! DOCTYPE html> 

The above native JS implementation-a simple example of the star rating system is all the content shared by xiaobian. I hope to give you a reference, and I hope you can provide more support to the customer's house.

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.