Giter Site home page Giter Site logo

nguyenbathanh / jquery-check-all Goto Github PK

View Code? Open in Web Editor NEW

This project forked from markgx/jquery-check-all

0.0 1.0 0.0 200 KB

Quickly add check all/uncheck all functionality to your forms or tables.

Home Page: http://markgx.github.io/jquery-check-all

HTML 1.04% CSS 7.06% JavaScript 91.90%

jquery-check-all's Introduction

jQuery Check All

http://markgx.github.io/jquery-check-all

A jQuery plugin which allows you to quickly add check all/uncheck all functionality to your forms or tables.

Download / Fork

Source is available on GitHub.

Setup

Include jQuery and the script somewhere on your page.

<script src="jquery.js"></script>
<script src="jquery-check-all.js"></script>

You'll have markup which contains your checkboxes, for example:

<table>
  <thead>
    <tr>
      <td><input id="check-all" type="checkbox"></td>
      <td></td>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><input type="checkbox" value="1"></td>
      <td>option 1</td>
    </tr>
    <tr>
      <td><input type="checkbox" value="2"></td>
      <td>option 2</td>
    </tr>
    <tr>
      <td><input type="checkbox" value="3"></td>
      <td>option 3</td>
    </tr>
  </tbody>
</table>

Call the checkAll() function on your "check all" checkbox to initialize the plugin.

<script>
  $(document).ready(function() {
    $('#check-all').checkAll();
  });
</script>

Options

The plugin can be supplied with an options object to further filter which checkboxes you want to group.

var options = { container: $('#table'), showIndeterminate: true };
$('#check-all-box').checkAll(options);

Alternatively, options may be supplied via data attributes. Note that options passed via the options object will override any options specified via data attributes.

<input id="check-all" type="checkbox" data-show-indeterminate="true">

Available options:

  • container: A selector string or jQuery object of the element which contains the children checkboxes. Defaults to document.
  • childCheckboxes: A selector string or jQuery object of the children checkboxes. Defaults to input[type=checkbox]. Note: if you supply this option, make sure what you're passing are checkboxes.
  • showIndeterminate: a boolean which specifies whether to display the check all checkbox in the indeterminate state if a subset of the children checkboxes are selected.

Requirements

  • jQuery 1.7+/2.0+

License

Released under the MIT License.

jquery-check-all's People

Contributors

craig410 avatar markgx avatar

Watchers

 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.