I'm currently trying to develop a darkmode feature for my website using jQuery's toggle method. At this point when the toggle is clicked the body colour changes, however, I wish for the header background colour to also change. How can I accomplish this?
current code base
$(document).ready(function(){
$('#checkbox').click(function(){
var element = document.body;
element.classList.toggle("dark");
});
});
</script>
As seen you can use document.body
to change the content of the body. I wish to achieve the same affect but for the header(and subsequently other elements)
P.S Jquery is mandatory