vendredi 5 octobre 2018

jQuery - update length live, not on pageload only

I have a large form on my site which contains a lot of checkboxes. A small jQuery script is counting the number of unchecked checkboxes and outputs the length in the HTML.

I use this:

                jQuery(document).ready(function($) {
                    var BoxesUnchecked = $('section.gearset input:checkbox:not(:checked)').length;
                    $('h3.gs-hook').html('The are ' + BoxesUnchecked + ' unchecked Items');
                });

The checked-state of the checkboxes is saved via cookie. My problem is that the above script only updates after page reload. But I want the length to change whenever another checkbox is checked or unchecked. Basically a live update of the length value.

How can I do this?




Aucun commentaire:

Enregistrer un commentaire