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

前端 未结 5 941
伪装坚强ぢ
伪装坚强ぢ 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:23

    you should set the innerHTML value like

     var myDivValue = document.getElementById("my_div").innerHTML = "Hello";
    

提交回复
热议问题