What event to hang on the input box with the checkbox to track its changes?
Hanged the event 'change':
var settingsDisableGroupButton = document.getElementById('disable-group-titles'); function disableGroupTitles(event) { console.log('changed'); var typeGroupTitles = $('.type-titles'); typeGroupTitles.toggleClass('type-titles_disabled'); } settingsDisableGroupButton.addEventListener('change', disableGroupTitles); But it does not work when we change the checked attribute of this object from a third-party function:
settingsDisableGroupButton.checked = !settingsDisableGroupButton.checked; A check mark is put in the checkbox, but the code that should be executed when changing the state does not work.