Today, I wrote another cool example: Star Scoring System (customizable number of stars, display information)
Sufustar.star ();
Use default value of 5 stars, default information
var msg = [...];
Sufustar.star (10,MSG);
The number of custom stars is 10, display information MSG format reference defaults, the number of bars must be the same as the number of stars;
Realize some examples, there is a benefit, can increase the use of knowledge points of proficiency, but also to test their own weak items! Once discovered, immediately turn the API document Evil repair!
I don't know if I am too stupid, this example actually wrote a whole day!
No nonsense, first of all, the knowledge points involved in this example:
1. Use CSS border to draw a triangle and add it to other elements with before;
2. Learn how to use CSS to locate elements;
3. Agents of learning events;
4. How to optimize performance;
The application of the match method of 5.String object, regular expression;
6. Registration event and event handling, the need to be compatible with IE;
7. Learn how to use ' | | ' Set default values for variables;
8. Simplify the code: take out the code that may have to be repeated, and write a separate function;
The following is a complete code with comments, encountered do not know to check the document it, to my current level can only be written like this, if there are good suggestions, welcome predecessors pointed out!
Above the original JS implementation-Star scoring system is a simple example of the small series to share all the content, I hope to give you a reference, but also hope that we support the cloud-dwelling community.