Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
104
rated 0 times [  110] [ 6]  / answers: 1 / hits: 20636  / 12 Years ago, mon, september 24, 2012, 12:00:00

I'm getting the following error for a simple function below:



TypeError: document.getElementsByTagName(p)[0].innerHtml is not a function


I'm just trying to understand the usage of getElementsByTagName.



function myFunc(){
document.getElementsByTagName(p)[0].innerHtml(hello my name is vaani);
}
</script>
</head>

<body onload=myFunc();>
<p></p>
<p></p>
<p></p>
</body>


Can someone tell me on where i'm going wrong?


More From » typeerror

 Answers
23

innerHTML but not innerHtml, and it is not a function, you should set the string to this property.



document.getElementsByTagName(p)[0].innerHTML = hello my name is vaani;

[#82940] Friday, September 21, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jimmieo

Total Points: 515
Total Questions: 102
Total Answers: 110

Location: Kazakhstan
Member since Mon, Sep 26, 2022
2 Years ago
;