jQuery Raty is a plugin that generates a customizable star rating automatically.
With default options:
$('#star').raty();
<div id="star"></div>
Started with a score and read only value:
$('#fixed').raty({
readOnly: true,
start: 2
});
<div id="fixed"></div>
With a custom score name and a number of stars:
$('#custom').raty({
scoreName: 'entity.score',
number: 10
});
<div id="custom"></div>
With a custom hint and icons:
$('#target').raty({
hintList: ['a', '', null, 'd', '5'],
starOn: 'medal-on.png',
starOff: 'medal-off.png'
});
<div id="target"></div>
Using onClick function:
$('#click').raty({
onClick: function(score) {
alert('score: ' + score);
}
});
<div id="click"></div>
Displaying half star:
$('#half').raty({
start: 3.3,
showHalf: true
});
<div id="half"></div>
With a default cancel button:
$('#cancel').raty({
showCancel: true
});
<div id="cancel"></div>
With a custom cancel button:
$('#cancel-custom').raty({
cancelHint: 'remove my rating!',
cancelPlace: 'right',
showCancel: true
onClick: function(score) {
alert('score: ' + score);
}
});
<div id="cancel-custom"></div>