$(this)
does not apply to the element on which the jRate
function is jRate
.
You can use a selector if there is only one element having this class
$('.star-rating').jRate({ startColor : '#ccc', endColor : '#ccc', readOnly : true, rating : $('.star-rating').data('star-rating') });
For multiple items:
Iterate over all elements that have a star-rating
class and bind the jRate
plugin individually using the rating
value of the corresponding element.
$('.star-rating').each(function () { $(this).jRate({ startColor: '#ccc', endColor: '#ccc', readOnly: true, rating: $(this).data('star-rating') }); });
JSFiddle Demo I did not find the CDN link of this plugin, so the added mini-code in the JavaScript panel itself
source share