HTML5 제작 방식 复主代码代码如下: < ;script src="http:// ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">><br>캔버스{ border:2px solid #000;}<br> <br> $(document).ready(function(){<br> var canvas=document.getElementById("draw");<br> var draw=canvas.getContext("2d");<br> draw.lineWidth=5; //线条粗细<br> draw.StrokeStyle="red" //颜color<br> var godraw=false; 🎜> <br> //按下鼠标<br> $("#draw").mousedown(function(e){<br> //准确坐标<br> var mouseX=e.pageX-this.offsetLeft;<br> var mouseY=e.pageY-this.offsetTop;<br> draw.moveTo(mouseX,mouseY);<br> godraw=true;</p> <p> })<br> //放开鼠标<br> $("#draw").mouseup(function(e){<br> godraw=false;<br> })<br> //移动鼠标<br> $("#draw").mousemove(function(e){<br> if(godraw){<br> var mouseX=e.pageX-this.offsetLeft;<br> var mouseY=e.pageY-this.offsetTop ;<br> draw.lineTo(mouseX 4,mouseY 4);<br> draw.Stroke();<br> }</p> <p> })<br> <br> })<br> 效果图