Skip to content Skip to sidebar Skip to footer

How To Add Canvas To Div Element Dynamically?

Can I add a canvas to body dynamically using java script? I know how to add a DIV element. There are many examples out there. But how to add a canvas into a DIV element? var iDiv =

Solution 1:

Yup, it works.

Check the rendered HTML or you can simply draw something & see for yourself. (DEMO)

innerDiv.getContext("2d").fillRect(50, 25, 100, 100);

Post a Comment for "How To Add Canvas To Div Element Dynamically?"