Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


<div class="container-fluid">
		<td>Звезды по умолчанию</td>
		<td><div id="stars-default"><input type=hidden name"rating"/></div></td>
		<td>Зеленый звезды с callback, а так же показывает текущее значение</td>
		<td><div id="stars-green" data-rating="4"></div></td>
		<td>Десять сердечек!</td>
		<td><div id="stars-herats" data-rating="6"></div></td>





                //the $(document).ready() function is down at the bottom

(function($) {

  $.fn.rating = function(method, options) {
    method = method || 'create';
    // This is the easiest way to have default options.
    var settings = $.extend({
      // These are the defaults.
      limit: 5,
      value: 0,
      glyph: "glyphicon-star",
      coloroff: "gray",
      coloron: "gold",
      size: "2.0em",
      cursor: "default",
      onClick: function() {},
      endofarray: "idontmatter"
    }, options);
    var style = "";
    style = style + "font-size:" + settings.size + "; ";
    style = style + "color:" + settings.coloroff + "; ";
    style = style + "cursor:" + settings.cursor + "; ";

    if (method == 'create') {
      //this.html('');	//junk whatever was there

      //initialize the data-rating property
      this.each(function() {
        attr = $(this).attr('data-rating');
        if (attr === undefined || attr === false) {
          $(this).attr('data-rating', settings.value);

      //bolt in the glyphs
      for (var i = 0; i < settings.limit; i++) {
        this.append('<span data-value="' + (i + 1) + '" class="ratingicon glyphicon ' + settings.glyph + '" style="' + style + '" aria-hidden="true"></span>');

      this.each(function() {

    if (method == 'set') {
      this.attr('data-rating', options);
      this.each(function() {
    if (method == 'get') {
      return this.attr('data-rating');
    //register the click events
    this.find("span.ratingicon").click(function() {
      rating = $(this).attr('data-value')
      $(this).parent().attr('data-rating', rating);

    function paint(div) {
      rating = parseInt(div.attr('data-rating'));
      div.find("input").val(rating); //if there is an input in the div lets set it's value
      div.find("span.ratingicon").each(function() { //now paint the stars

        var rating = parseInt($(this).parent().attr('data-rating'));
        var value = parseInt($(this).attr('data-value'));
        if (value > rating) {
          $(this).css('color', settings.coloroff);
        } else {
          $(this).css('color', settings.coloron);



$(document).ready(function() {

  $("#stars-green").rating('create', {
    coloron: 'green',
    onClick: function() {
      alert('rating is ' + this.attr('data-rating'));
  $("#stars-herats").rating('create', {
    coloron: 'red',
    limit: 10,
    glyph: 'glyphicon-heart'