html中怎么动态生成多个canvas
1个回答
推荐于2016-03-12
展开全部
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<TITLE>New Document </TITLE>
<script type="text/javascript">
function drawCanvas(){
var canvas = document.getElementById('myCanvas');
canvas.width=100;
canvas.height=100;
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#FF0000';
ctx.fillRect(10, 10, 30, 30);
}
</script>
</HEAD>
<BODY>
<input type="button" value="test" onclick="drawCanvas();"><hr>
<canvas style="background:blue;" height="200" width="200" id="myCanvas">
your browser does not support the canvas tag
</canvas>
</BODY>
</HTML>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询