Link to home
Create AccountLog in
Avatar of tonelm54
tonelm54

asked on

Add Handler to all and then call them all

Im trying to add a handler to all checkboxes:-
                $('document').ready(function () {
                    $(':checkbox').change(function () {
                      alert((this).id());
                      });
                });

Open in new window


And then call them all by:-
 $(':checkbox').are(':checked').trigger('change'); 

Open in new window


The idea is to add a save to each element, so when the value is saved it executes a ajax request to save the value, but when then are all disabled (done by a button called disableAll) I want it to run the save code on all of the elements (ie run the onChange handler on all the elements).

Something is happening with the trigger as the code takes a few seconds to run, but what I dont know as it doesnt display any alert boxes to me.

Can anyone assist?
Avatar of Jagadishwor Dulal
Jagadishwor Dulal
Flag of Nepal image

Do you want single check-box to handle all other check-boxes  see jsfiddle:

http://jsfiddle.net/j08691/pzCcE/2/
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer