what am i doing wrong here?
<body>
<div></div>
<script>
var x = 5, y = 2;
x += y;
document.getElementsByTagName('div').innerHTML = x;
</script>
what am i doing wrong here?
<body>
<div></div>
<script>
var x = 5, y = 2;
x += y;
document.getElementsByTagName('div').innerHTML = x;
</script>
“The Element.getElementsByTagName() method returns a live HTMLCollection of elements with the given tag name.”
The live collection it returns is not a single element but rather like an array:
After reading the above documentation how do you think you would access the <div>?
Ya, Makes sense now.This is just my second day of understanding JS in depth.Thank you!