I have a function that adds a CSS class to all "a" selectors when I click on the button, unfortunately when I refresh the page or go to another tab its result is lost and I have to click on the button again. How can I fix this?
JS code:
function underlineLinks() {
const links = document.querySelectorAll("a");
links.forEach(a => a.classList.toggle("underline-links"));
}
CSS:
.underline-links {
text-decoration: underline!important; }