Javascript innerHTML is not getting updated

后端 未结 5 1863
抹茶落季
抹茶落季 2021-01-29 00:39

Hi I am trying to update the innerHTML of following script



        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-29 01:08

    See the comments inline:

    // Run when document is completely rendered and is ready to be manipulated 
    document.addEventListener("DOMContentLoaded", function () {
        document.querySelector("#global-alert-queue .animate-in").innerHTML = "Change Text";
    });
    

    Demo: http://jsfiddle.net/tusharj/kg3cc4gw/3/

    querySelector

    Returns the first element within the document (using depth-first pre-order traversal of the document's nodes) that matches the specified group of selectors.

    More on querySelector: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector

提交回复
热议问题