<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>document</title>
</head>
<body>
<canvas id="mycanvas" width="800" height="500"
style="border:1px solid #000000;">您的浏览器不支持canvas
</canvas>
<script type="text/javascript">
var c =document.queryselector('#mycanvas');
// 标识画布并指明上下文
var ctx = c.getcontext('2d');
ctx.strokestyle = '#000';
ctx.linewidth = 3;
c.onmousedown = function (ev){
ctx.beginpath();
ctx.moveto(ev.clientx,ev.clienty)
c.onmousemove = function (ev) {
ctx.lineto(ev.clientx,ev.clienty);
ctx.stroke()
}
c.onmouseup = function () {
c.onmousemove = null;
}
}
</script>
</body>
</html>