I'm want to change background color using checkbox, but it work only once. Mean if i click it again nothing change.
<body>
<label class="switch">
<input type="checkbox" onclick="check();">
<span class="slider round"></span>
</label>
</body>
<script>
function check() {
if (document.getElementsByTagName('input').checked) {
document.body.style.backgroundColor = 'white';
} else {
document.body.style.backgroundColor = 'black';
}
}
</script>