I would like to change the color, fontsize and font weight of the text in a span element of the html page.
I am using the following code:
if(window.locat
Add your to the bottom of your
, or add an event listener for
DOMContentLoaded
following this StackOverflow question.
If that script executes in the section of the code,
document.getElementsByClassName(...)
will return an empty array because the DOM is not loaded yet.
You're getting the Type Error
because you're referencing search_span[0]
, but search_span[0]
is undefined
.
This works when you execute it in Dev Tools because the DOM is already loaded.