I am kind of confused why my code doesn\'t work correctly, I hope You will tell me what I\'ve done wrong. I want to highlight navigation tab while clicked.
HTML:
This code will highlight the navigation tab without needing to include onclick in the HTML, though it doesn't remove the background color if another tab is clicked.
document.onclick = function(event) {
var target = event.target || event.srcElement;
target.style.background = '#cf5c3f';
};
https://codepen.io/mdmcginn/pen/BwrNaj/