Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

Save Automatically?

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              <div class="container">
  <h3>jQuery Checkbox Buttons<br />
    <small>Buttons that change the state of their own hidden checkboxes, and vice-versa!<br>
      Source: <a>https://bootsnipp.com/snippets/featured/jquery-checkbox-buttons</a>
    </small>
  </h3>
  
  <hr>
  
  <br>
  
  <div class="input-group col-md-4">
    <span class="button-checkbox input-group-btn">
      <button type="button" class="btn" data-color="primary">Option One</button>
      <input type="checkbox" class="hidden" checked />
    </span>
    <span class="button-checkbox input-group-btn">
      <button type="button" class="btn" data-color="primary">Option Two</button>
      <input type="checkbox" class="hidden" />
    </span>
    <span class="button-checkbox input-group-btn">
      <input type="checkbox" class="hidden" checked />
      <button type="button" class="btn" data-color="primary">Option Three</button>
    </span>
  </div>
            
          
!

CSS

            
              *:focus {
  outline: none !important;
}

.input-group-btn .btn {
  width: 100%;
}

:not(:first-child):not(:last-child).input-group-btn.button-checkbox .btn {
  border-radius: 0px;
}
            
          
!

JS

            
              $(function () {
  $('.button-checkbox').each(function () {

    // Settings
    var $widget = $(this),
        $button = $widget.find('button'),
        $checkbox = $widget.find('input:checkbox'),
        color = $button.data('color'),
        settings = {
          on: {
            icon: ''//'glyphicon glyphicon-check'
          },
          off: {
            icon: ''//'glyphicon glyphicon-unchecked'
          }
        };

    // Event Handlers
    $button.on('click', function () {
      $checkbox.prop('checked', !$checkbox.is(':checked'));
      $checkbox.triggerHandler('change');
      updateDisplay();
    });
    $checkbox.on('change', function () {
      updateDisplay();
    });

    // Actions
    function updateDisplay() {
      var isChecked = $checkbox.is(':checked');

      // Set the button's state
      $button.data('state', (isChecked) ? "on" : "off");

      // Set the button's icon
      $button.find('.state-icon')
        .removeClass()
        .addClass('state-icon ' + settings[$button.data('state')].icon);

      // Update the button's color
      if (isChecked) {
        $button
          .removeClass('btn-default')
          .addClass('btn-' + color + ' active');
      }
      else {
        $button
          .removeClass('btn-' + color + ' active')
          .addClass('btn-default');
      }
    }

    // Initialization
    function init() {

      updateDisplay();

      // Inject the icon if applicable
      if ($button.find('.state-icon').length == 0) {
        $button.prepend('<i class="state-icon ' + settings[$button.data('state')].icon + '"></i> ');
      }
    }
    init();
  });
});
            
          
!
999px

Console