star-rating-svg.js
Github / v.1.3.0
examples
Basic implementation
<div class="my-rating"></div>
$(".my-rating").starRating({ initialRating: 4, strokeColor: '#894A00', strokeWidth: 10, starSize: 25 });
Rounded star shape
<div> class="my-rating-4" data-rating="2.5"></div>
$(".my-rating-4").starRating({ totalStars: 5, starShape: 'rounded', starSize: 40, emptyColor: 'lightgray', hoverColor: 'salmon', activeColor: 'crimson', useGradient: false });
Use gradients
<div> class="my-rating-5"></div>
// specify the gradient start and end for the selected stars $(".my-rating-5").starRating({ starSize: 80, strokeWidth: 9, strokeColor: 'black', initialRating: 2, starGradient: { start: '#93BFE2', end: '#105694' } });
Execute callback when rating
<div> class="my-rating-6"></div>
$(".my-rating-6").starRating({ totalStars: 5, emptyColor: 'lightgray', hoverColor: 'salmon', activeColor: 'cornflowerblue', initialRating: 4, strokeWidth: 0, useGradient: false, minRating: 1, callback: function(currentRating, $el){ alert('rated ' + currentRating); console.log('DOM element ', $el); } });
read only mode
<div> class="my-rating-7"></div>
$(".my-rating-7").starRating({ readOnly: true });
Use fullstars
// use full stars only <div> class="my-rating-8"></div>
$(".my-rating-8").starRating({ useFullStars: true });
On hover event
<span> class="my-rating-9"></span> <span> class="live-rating"></span>
$(".my-rating-9").starRating({ initialRating: 3.5, disableAfterRate: false, onHover: function(currentIndex, currentRating, $el){ $('.live-rating').text(currentIndex); }, onLeave: function(currentIndex, currentRating, $el){ $('.live-rating').text(currentRating); } });
rating level colors
<div> class="my-rating-10"></div>
// specify the color per rating level $(".my-rating-10").starRating({ starSize: 80, strokeWidth: 9, strokeColor: 'black', ratedColors: ['#e2c181', '#ffa700', '#c4573e', '#9a321a', '#5e1e0f'] initialRating: 2, });