Add canvas to a page with javascript

前端 未结 3 673
半阙折子戏
半阙折子戏 2020-12-14 05:50

I am trying to use Javascript in order to add a canvas to one page which originally does not have one. I am trying to do the following:

var canv=document.cre         


        
3条回答
  •  眼角桃花
    2020-12-14 06:37

    var canv=document.createElement("canvas");
    canv.setAttribute("id", "canvasID");
    document.body.appendChild(canv);
    

    Without something like that third line, your new canvas is never actually inserted into the page.

提交回复
热议问题