Skip to content Skip to sidebar Skip to footer

Why Isn't Getelementsbyclassname Working?

I can't understand why getElementsByClassName isn't working here.

Solution 1:

  1. The function name is getElementsByClassName, not getElementByClassName
  2. getElementsByClassName returns an array-like object of elements, not the one of elements.

Code should look like this:

n = newDate();
y = n.getFullYear();
document.getElementsByClassName("date")[0].innerHTML = y;
<spanclass="date"></span> CompanyName

Post a Comment for "Why Isn't Getelementsbyclassname Working?"