Why is code after [removed]() not executed?

前端 未结 8 400
长情又很酷
长情又很酷 2021-01-21 07:36

I have the follwing JavaScript.


    
        

        
8条回答
  •  感情败类
    2021-01-21 08:16

    document.write can only be used during the initial loading of the document.

    If you want to insert your H1 when the function is called, you may replace

    document.write("

    Just a javascript demo

    ");

    with

    var h1 = document.createElement('h1');
    h1.innerHTML = " Just a javascript demo";
    document.body.appendChild(h1);
    

提交回复
热议问题