vendredi 29 novembre 2019

Save on localstorage appended checkbox state

I have this function:

function test() {
    var a = document.getElementById('test');
    var b = document.createElement('input');
    b.type = 'checkbox';
    b.addEventListener( 'change', function() {
    if(this.checked) {
       //do something and save the state (checked)
    } else {
       //do something else and save the state(not checked)
    }
}

and I want to save the state of the checkbox on localstorage from the appended checkbox, what is the best way to do it?




Aucun commentaire:

Enregistrer un commentaire