X

LATEST #JQUERY NEWS

jQuery Snippets: Check/Un-Check All Function


This easy-to-implement jQuery code snippet is super useful, and can be used to create a functionality that will check OR uncheck any checkboxes within a particular fieldeset. So for example, if your HTML looks like this:

<fieldset>
   <div><input type=“checkbox” class=“checkall”>Check All</div>
   <div><input type=“checkbox”>Check Me</div>
   <div><input type=“checkbox”>Check Me</div>
   <div><input type=“checkbox”>Check Me</div>
</fieldset>

Your jQuery code to make the .checkall class actually check all of the checkbox inputs should look something like this:

$(function() {
    $('.checkall').click(function() {
        $(this).parents('fieldset:eq(0)').find(':checkbox').attr('checked', this.checked);
    });
});

With the above code, you can easily add a “Check All” button to any of your fieldset elements.

Recently Published

article image
»

7 Responsive jQuery Dropdown Menu Plugins

Dropdown Menu Plugins Dropdown menus are mostly used for website ...

article image
»

20 Stylish and Modern jQuery Tooltip Plugins

jQuery Tooltip Plugins Tooltips are a great option for showing extra ...

article image
»

15 Newest jQuery plugins for responsive website

Due to the proliferation of smartphones and tablets, responsive ...

article image
»

How to use Redux with jQuery

State management is one of most integral parts of any software and a ...

article image
»

Fade HTML Table Row on Hover Using jQuery

HTML tables are the ideal choice for displaying data in tabular form. ...

article image
»

Drag and Drop HTML Table Rows Using jQuery

HTML tables are the preferred UI option for displaying data. Sorting, ...

article image
»

Top 5 Best JavaScript Template Engines

Template engines help in the decoupling of HTML and JavaScript code ...

article image
»

3 jQuery/JavaScript Plugins for Push Notifications

Push notifications started from the mobile business but this ...

article image
»

Create Smooth Animation Using jQuery’s “stop()”

Making Quick Work jQuery’s animate() method is a quick way to ...