Small Star Rating Plugin With jQuery - rating.js

File Size: 34.3 KB
Views Total: 3678
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Small Star Rating Plugin With jQuery - rating.js

rating.js is a really small and cross-browser jQuery plugin which lets you render star rating controls using text fields and CSS image sprites.

How to use it:

1. Add references to jQuery library and the jQuery rating.js plugin's files as this:

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="rating.js"></script>
<link rel="stylesheet" href="rating.css">

2. Create a normal input field for the star rating control.

<input type="text" class="rating">

3. Initialize the plugin to render a default star rating control on the webpage.

$('.rating').rating();

4. Set the initial value of your star rating control.

<input type="text" class="rating" value="3">

5. Return the selected value using the rateEnd callback:

$('.rating').rating({ 
  rateEnd: function (v) { 
    $('#result').text(v); 
  } 
});

This awesome jQuery plugin is developed by mahongtao. For more Advanced Usages, please check the demo page or visit the official website.