i have such a javascript code to create an input and when its checked add a style id tag to add line through but i am getting this error.
Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')"
const checkBox=document.createElement("input")
checkBox.className="form-check-input me-1 fa-pull-right"
checkBox.type="checkbox"
li.appendChild(checkBox);
checkBox.id="checkBox";
checkBox.addEventListener('change', function(e){
if(checkBox.checked){
li.setAttribute=("id","completed");
} else
li.removeAttribute=("id","completed");
});
Aucun commentaire:
Enregistrer un commentaire