I tested my function by calling it when the button on the page is clicked and it works fine but when I call the function with window.onload it changes color for a moment and goes back to original color defined in CSS. I'm guessing there's a problem with calling the function onload or something to do with Blazor project itself. I also tried moving my js script in body or head but it doesn't do anything. I tried replacing the CSS class with another one using Jquery and I get the same effect.
Javascript:
window.onload = function () {
if (window.location.href.match('https://localhost:44322/blog') != null) {
document.querySelector('.logo').style.color = "#000";
}
};
CSS:
.logo {
font-size: 1.1rem;
font-weight: 300;
letter-spacing: 2px;
text-transform: uppercase;
line-height: 3rem;
padding: 0 10px;
margin-top: 9px;
color: #fff;
}
HTML:
<h3 class="logo">
Some <span>Text</span>
</h3>