This time I will share jQuery Plugin and tutorial about Simple Star Rating Plugin with jQuery and Font Awesome – Raterater, hope it will help you in programming stack.
Raterater is an easy-to-use jQuery based 5 star rating widget that uses Font Awesome 4 for scalable & styleable star icons.
How to use it:
1. Load the latest Font Awesome 4 in the head section of the web page.
1 |
< link href = "//netdna.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel = "stylesheet" > |
2. Load the jQuery raterater plugin anywhere on the web page, but after loading jQuery library.
2 |
< script src = "raterater.jquery.js" ></ script > |
3. Create a container element for the star rating widget and use data-rating
attribute to specify the current star fractions.
1 |
< div class = "ratebox" data-id = "1" data-rating = "4.7" ></ div > |
4. The core CSS to style the star rating widget.
01 |
.raterater-wrapper { overflow : visible ; } |
12 |
.raterater-hover-layer { display : none ; } |
14 |
.raterater-hover-layer i, |
15 |
.raterater-rating-layer i { |
5. Call the function to enable the star rating widget.
02 |
$( '.demo' ).raterater({ |
05 |
submitFunction: 'rateAlert' , |
6. Callback function when a rating is chosen.
1 |
function rateAlert(id, rating){ |
2 |
alert( 'Rating for ' +id+ ' is ' +rating+ ' stars!' ); |
7. Override star colors as you wish.
1 |
.raterater-bg-layer { color : #95a5a6 ; } |
3 |
.raterater-hover-layer { color : #f1c40f ; } |
5 |
.raterater-hover-layer.rated { color : #f1c40f ; } |
7 |
.raterater-rating-layer { color : #f39c12 ; } |
9 |
.raterater-outline-layer { color : #7f8c8d ; } |
Change logs:
2015-11-28
- Trigger .change() on input for reactive frameworks
2015-10-02
- add step option for ratings
2015-09-06
- Update raterater.jquery.js
2015-08-19
This awesome jQuery plugin is developed by bainmullins. For more Advanced Usages, please check the demo page or visit the official website.