there is a simple markup. I need to cross text in the same table row as checkbox when checkbox change state to 'checked'. any help appreciated
function watcher(){
var checkboxElements = document.getElementsByClassName("checkbox");
for(var i = 0; i<checkboxElements.length; i++){
checkboxElements[i].addEventListener('change', function(){
if(checkboxElements[i].checked === true) {
table.querySelector("table").rows[i].style.textDecoration = 'line-through';
}
});
}
}
<table class='table'>
<tr>
<td>
<input class='checkbox' type='checkbox'>
</td>
<td>
test
</td>
</tr>
<tr>
<td>
<input class='checkbox' type='checkbox'>
</td>
<td>
test
</td>
</tr>
</table>
my code seems doesn't work
Aucun commentaire:
Enregistrer un commentaire