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

前端 未结 2 555
甜味超标
甜味超标 2020-12-03 21:21

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

TypeError: document.getElementsByTagName(\"p\")[0].innerHtml is not a function
<
相关标签:
2条回答
  • 2020-12-03 22:03

    use

    document.getElementsByTagName("p")[0].innerHTML="hello my name is vaani";
    
    0 讨论(0)
  • 2020-12-03 22:10

    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";
    
    0 讨论(0)
提交回复
热议问题