lundi 16 janvier 2017

How to also run a change function on page load?

On a "create" page, I have a lot of stuff happening with checkboxes when one of them is either checked or unchecked, using...

$('.option').on('change', function() {
//lots of stuff
});

I have these checkboxes on an "edit" page as well, so when the "edit" page loads, it's setting all the checkboxes properly (check or unchecked), but there are also some math calculations done onchange that I need done on page load. In other words, for the displayed numbers to be correct when the edit page is first opened, I need the "change" function above to run on page load.

Is that doable? Basically want it to run on page load, and then again whenever there is an actual "change" (as originally intended).




Aucun commentaire:

Enregistrer un commentaire