0
return hello + text.value in js
I know its messy but I want it to work https://code.sololearn.com/WxI5aiqcyf7D/?ref=app
6 Réponses
+ 5
bop cho
In html, we can have same class name in every element. So you have to get elements using getElementsByClassName. Though it returns an array so I have taken first element.
function hello()
{
var name = document.getElementsByClassName('text')[0];
alert('hello,' + name.value);
}
+ 4
bop cho
It's a small q
querySelector
+ 2
running the code you get ‚document.getElementByClass is not a function....‘ This is because, well, getElementByClass is not a function. One way would be to instead use document.querySelector(".text"). Note the dot to tell that text is a class
+ 1
I Am Groot ! getElementsByClassName does not return an array. it returns an HTMLCollection
+ 1
I love u Groot, man!
0
I Am Groot ! John Doe ok, guys now pls look at it now and tell me what's wrong