0
Why it's showing undefined?
I want to output the value of all p tags but it's showing undefined!! https://code.sololearn.com/Wr3OQ41hV0w4/?ref=app
7 ответов
+ 6
Technical Code
html tags except form elements (input, textarea) doens't contains attribute value means you can't get using value. Use innerHTML.
The getElementsByTagName() method returns a collection of an elements's child elements with the specified tag name.
Try this
console.log(p[0].innerHTML)
https://code.sololearn.com/WGF8l304g4kx/?ref=app
+ 3
Technical Code Your Code is working properly according to me.
But yeah, it is showing undefined that I don't understand too.
+ 2
ODLNT
Array is also a collection.
+ 2
Thank you very much I Am AJ !
+ 1
I Am AJ ! getElementsByTagName, does it return an array or a collection?
+ 1
ODLNT Actually it's a collection of Nodes.
0
console.log(p[1].value) ?