I would like that whenever you click on a checkbox, a value is printed to the console that corresponds to the state of the checkbox (on/off). I know there are threads with similar titles but all those I've seen don't have clear examples.
Here's what I got so far
(Turn on Console and click Add library, JQuery1.8.3):
This only prints when the page is loaded, I want it to print whenever I click on it.
This snippet toggles an on and off value whenever I click on the checkbox, but the box doesn't display the tick symbol anymore when it is toggled on.
event.preventDefault()for the click-event. The default-action for a click on a checkbox is toggling the checked-property. Because of that you shouldn't usetoggle()on elements where you want to proceed with the default click-action(e.g. links, submit-buttons etc. )