Code Monkey home page Code Monkey logo

rating's Introduction

Rating

Rating is a super simple jQuery plugin that quickly and easily lets you add a star rating input field like below.

Rating image

It's quick and super simple to use.

Example

This plugin needs jQuery, after that, all you need to do is supply the element selector.

<form action="" method="post">
    <div id="rating"></div>
    <input type="submit" value="Rate">
</form>
$(document).ready(function() {
    rating.create({
        'selector': '#rating'
    });
});

Result

codeResult

Parameters

There are a number of different options that you can pass through to customise your new input further.

Required

selector - The selector of the element that you want the rating system to be added to.

Optional

selectedIcon - Which image you want to be displayed for selected ratings. Default: selectedIconImage

unselectedIcon - Which image you want to be display for unselected ratings. Default: unselectedIconImage

outOf - The highest possible rating that can be given. Default: 5

defaultRating - The number of "stars" that you want selected by default. Default: 3

name - The name of the input field that you want to be passed to your form handler. Default: rating

ratingClass - Array of classes that you want to be added to each rating "star". Default: null

Using Font Awesome

You can use font awesome icons by adding the same class that you would add in an i tag as the selectedIcon and unselectedIcon. Note - if you use font awesome for one of the icons, you have to use it for both icons. Also, if you use font awesome, you cannot use the ratingClass attribute, instead you should add your classes onto the icon definition, see below.

Example:

$(document).ready(function() {
    rating.create({
        'selector': '#rating',
        'unselectedIcon': 'fa fa-star-o red-font',
        'selectedIcon': 'fa fa-star'
    });
});

rating's People

Contributors

drroach avatar

Watchers

hadi avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.