Skip to content

Repository files navigation

Overview

The Star Rating Plugin is a plugin for the jQuery Javascript library that creates a non-obstrusive star rating control based on a set of radio input boxes.

Installation

Basic Usage

Simple stars

Just add the class="star" to your radio boxes:

<inputname="star1" type="radio" class="star"/><inputname="star1" type="radio" class="star"/><inputname="star1" type="radio" class="star"/><inputname="star1" type="radio" class="star"/><inputname="star1" type="radio" class="star"/>

Specifying a default value

Use the checked property to specify the initial/default value of the control

<inputname="star2" type="radio" class="star"/><inputname="star2" type="radio" class="star"/><inputname="star2" type="radio" class="star" checked="checked"/><inputname="star2" type="radio" class="star"/><inputname="star2" type="radio" class="star"/>

Read-only stars

Use the disabled property to use a control for display purposes only

<inputname="star3" type="radio" class="star" disabled="disabled"/><inputname="star3" type="radio" class="star" disabled="disabled"/><inputname="star3" type="radio" class="star" disabled="disabled" checked="checked"/><inputname="star3" type="radio" class="star" disabled="disabled"/><inputname="star3" type="radio" class="star" disabled="disabled"/>

Split-stars with the metadata plugin

Use the metadata plugin to pass advanced settings to the plugin via the class property. The example below creates 4 total stars with a selected value of 1.25 (1 and a quarter star). The total number of stars is the number of radios divided by the split, in this case 16/4 = 4. The number of stars selected is the ordinal value of the radio selected divided by the split, in this case 5/4 = 1.25

<inputname="adv1" type="radio" class="star {split:4}"/><inputname="adv1" type="radio" class="star {split:4}"/><inputname="adv1" type="radio" class="star {split:4}"/><inputname="adv1" type="radio" class="star {split:4}"/><inputname="adv1" type="radio" class="star {split:4}" checked="checked"/><inputname="adv1" type="radio" class="star {split:4}"/><inputname="adv1" type="radio" class="star {split:4}"/><inputname="adv1" type="radio" class="star {split:4}"/><inputname="adv1" type="radio" class="star {split:4}"/><inputname="adv1" type="radio" class="star {split:4}"/><inputname="adv1" type="radio" class="star {split:4}"/><inputname="adv1" type="radio" class="star {split:4}"/><inputname="adv1" type="radio" class="star {split:4}"/><inputname="adv1" type="radio" class="star {split:4}"/><inputname="adv1" type="radio" class="star {split:4}"/><inputname="adv1" type="radio" class="star {split:4}"/>

Options

The rating method takes several options. They are each detailed here:

optiontypedefaultDescription
cancelstring"Cancel Rating"Advisory title for the 'cancel' link
cancelValuestring""Value to submit when user click the 'cancel' link
splitinteger0Number of parts to split the star into
starWidthinteger16Width of star image in case the plugin can't work it out. This can happen if the jQuery.dimensions plugin is not available OR the image is hidden at installation
halfbooleannullShortcut for split: 2
requiredbooleannullDisables the 'cancel' button so user can only select one of the specified values
readOnlybooleannullDisable rating plugin interaction
focusfunctionnullCallback function, executed when stars are focused
blurfunctionnullCallback function, executed when stars are focused
callbackfunctionnullCallback function, executed when a star is clicked

License

This project is licensed under the MIT license. See LICENSE file.

About

jQuery Star Rating Plugin

Resources

Stars

32 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages