I have a table with rows that look like this: ( 'o' is a checkbox)
_________________________________________
| o | some label | textarea | o |
|___|______________|___________|_________|
Now I want to check the left checkbox when the cell it's in is clicked.
I managed to let this happen, but somehow now the checkbox itself won't (un-)check if it's clicked.
This is the javascript code I've written:
const cb = document.querySelectorAll('.checkbox');
cb.forEach(e => {
e.addEventListener('click', function() {
const checkbox = e.parentNode.querySelector('.checkbox input');
checkbox.checked = !checkbox.checked;
});
});
How do I solve this?
Aucun commentaire:
Enregistrer un commentaire