How to have 2 or more canvas in the same page.. not as layers
I have a page where I've 2 canvas. One for tracking mouse position and another for simple drawing. Both the code are working but not as expected.
- Both the canvas got pushed down..
- Displays both the canvas but
- Uses only one o开发者_开发技巧f the canvas to display the results
. Why?? Here is the link to my page Canvas, Expected Output
You were appending both canvas elements each time. Heres the area of code that does it, and a quick check i put in place.
if(flag ===1){
canvasDiv1.appendChild(canvas);
}else{
canvasDiv2.appendChild(canvas);
}
Here is a link to the full code, and what I assume you were going for.
http://jsfiddle.net/loktar/R3hyg/
精彩评论