[Vuejs]-InnerText and InnerHTML value undefined, even the value exist

1👍

the browser does not know how many element with that class there are, since your using a class there could be multiple. therefore document.getElementsByClass() returns an array of all the elements that contain that class.

so either you could use ID’s or you could do something like:

document.getElementsByClass("some-class")[0].innerHTML;

ofcourse if you dont know the specific index you could just use a variable

0👍

getElementByClassName returns an Array of Elements not the Element so if there is still only element in the Array you have to first access the first Element from Array and then try to user innerHTML or something else

Leave a comment