I want to assign the date to a variable I have tried with var $x = document.getElementsByTagName("span").innerHtml but this assigns null value
Asked
Active
Viewed 56 times
0
-
1theres no `getElementByTagName` - theres `getElement*s*ByTagName`, but that returns a `NodeList`. – Daniel A. White Apr 20 '20 at 13:49
-
look at using `querySelector()` or `getElementsByClassName()`. `getElementByTagName` isn't a valid method as you are missing an 's', and will return a collection regardless if you used it (so innerHTML won't work on its return value) – Nick Parsons Apr 20 '20 at 13:49
1 Answers
0
You can get value with selector too.
document.querySelector("{SELECTOR}").innerHTML;
You can copy any selector with right click from Chrome Developer Console.

Onurgule
- 707
- 8
- 21