samedi 4 juillet 2020

Check and uncheck checkbox with vanilla javascript [duplicate]

Very basic question here, I am using a JS library to add keyboard shortcuts, I want to check and uncheck a checkbox using the same line of commands, but I am not sure about how to do this, here is the code:

shortcuts.add('alt+s', function() {
        document.getElementById("menu-toggle").checked = true 
    })

How can I use the same shortcut to uncheck the same element?

        document.getElementById("menu-toggle").checked = false; 

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire