Skip to main content
added 69 characters in body
Source Link
Tushar
  • 87.4k
  • 21
  • 164
  • 182

$(this) doesn't refer to the element on which the jRate function is being called.

You can use the selector if there is only a single element having that class

$('.star-rating').jRate({
    startColor : '#ccc',
    endColor : '#ccc',
    readOnly : true,
    rating : $('.star-rating').data('star-rating')
});

For multiple elements:

Iterate over all the elements having the class star-rating and attach the plugin jRate individually with the rating value of the respective element.

$('.star-rating').each(function () {
    $(this).jRate({
        startColor: '#ccc',
        endColor: '#ccc',
        readOnly: true,
        rating: $(this).data('star-rating')
    });
});

JSFiddle DemoDidn't find CDN link of that plugin, so added the minified code in JavaScript pane itself

$(this) doesn't refer to the element on which the jRate function is being called.

You can use the selector if there is only a single element having that class

$('.star-rating').jRate({
    startColor : '#ccc',
    endColor : '#ccc',
    readOnly : true,
    rating : $('.star-rating').data('star-rating')
});

For multiple elements:

Iterate over all the elements having the class star-rating and attach the plugin jRate individually with the rating value of the respective element.

$('.star-rating').each(function () {
    $(this).jRate({
        startColor: '#ccc',
        endColor: '#ccc',
        readOnly: true,
        rating: $(this).data('star-rating')
    });
});

JSFiddle Demo

$(this) doesn't refer to the element on which the jRate function is being called.

You can use the selector if there is only a single element having that class

$('.star-rating').jRate({
    startColor : '#ccc',
    endColor : '#ccc',
    readOnly : true,
    rating : $('.star-rating').data('star-rating')
});

For multiple elements:

Iterate over all the elements having the class star-rating and attach the plugin jRate individually with the rating value of the respective element.

$('.star-rating').each(function () {
    $(this).jRate({
        startColor: '#ccc',
        endColor: '#ccc',
        readOnly: true,
        rating: $(this).data('star-rating')
    });
});

JSFiddle DemoDidn't find CDN link of that plugin, so added the minified code in JavaScript pane itself

added 69 characters in body
Source Link
Tushar
  • 87.4k
  • 21
  • 164
  • 182

$(this) doesn't refer to the element on which the jRate function is being called.

You can use the selector if there is only a single element having that class

$('.star-rating').jRate({
    startColor : '#ccc',
    endColor : '#ccc',
    readOnly : true,
    rating : $('.star-rating').data('star-rating')
});

For multiple elements:

Iterate over all the elements having the class star-rating and attach the plugin jRate individually with the rating value of the respective element.

$('.star-rating').each(function () {
    $(this).jRate({
        startColor: '#ccc',
        endColor: '#ccc',
        readOnly: true,
        rating: $(this).data('star-rating')
    });
});

JSFiddle Demo

$(this) doesn't refer to the element on which the jRate function is being called.

You can use the selector if there is only a single element having that class

$('.star-rating').jRate({
    startColor : '#ccc',
    endColor : '#ccc',
    readOnly : true,
    rating : $('.star-rating').data('star-rating')
});

For multiple elements:

Iterate over all the elements having the class star-rating and attach the plugin jRate individually with the rating value of the respective element.

$('.star-rating').each(function () {
    $(this).jRate({
        startColor: '#ccc',
        endColor: '#ccc',
        readOnly: true,
        rating: $(this).data('star-rating')
    });
});

$(this) doesn't refer to the element on which the jRate function is being called.

You can use the selector if there is only a single element having that class

$('.star-rating').jRate({
    startColor : '#ccc',
    endColor : '#ccc',
    readOnly : true,
    rating : $('.star-rating').data('star-rating')
});

For multiple elements:

Iterate over all the elements having the class star-rating and attach the plugin jRate individually with the rating value of the respective element.

$('.star-rating').each(function () {
    $(this).jRate({
        startColor: '#ccc',
        endColor: '#ccc',
        readOnly: true,
        rating: $(this).data('star-rating')
    });
});

JSFiddle Demo

Source Link
Tushar
  • 87.4k
  • 21
  • 164
  • 182

$(this) doesn't refer to the element on which the jRate function is being called.

You can use the selector if there is only a single element having that class

$('.star-rating').jRate({
    startColor : '#ccc',
    endColor : '#ccc',
    readOnly : true,
    rating : $('.star-rating').data('star-rating')
});

For multiple elements:

Iterate over all the elements having the class star-rating and attach the plugin jRate individually with the rating value of the respective element.

$('.star-rating').each(function () {
    $(this).jRate({
        startColor: '#ccc',
        endColor: '#ccc',
        readOnly: true,
        rating: $(this).data('star-rating')
    });
});