Setting innerHTML: Why won't it update the DOM?

前端 未结 5 949
伪装坚强ぢ
伪装坚强ぢ 2020-11-29 08:37

Wondering why I can\'t get document.getElementById(\"my_div\").innerHTML to update the DOM when I re-assign the variable. For example:

5条回答
  •  孤独总比滥情好
    2020-11-29 09:10

    For future googlers my problem was that I was calling the plural elements.

    document.getElementsByClassName(‘class’).innerHTML

    So it returned an Array not a single element. I changed it to the singular.

    document.getElementByClassName(‘class’).innerHTML

    That made it so I could update the innerHTML value.

提交回复
热议问题