码迷,mamicode.com
首页 > Web开发 > 详细

jquery canvas 用户点击记录

时间:2015-09-10 15:52:10      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

<div style="width:200px; height:20px; position:fixed; top:0; left:0; background-color:blue;">
	<span id="x"></span>-
	<span id="y"></span>-
	<span id="v"></span>-
	<span id="w"></span>
</div>
<script>
$(‘html‘).mousemove(function(){
	$("#x").text(event.pageX);
	$("#y").text(event.pageY);
	$("#v").text(event.clientX);
	$("#w").text(event.clientY);		
})
$(‘html‘).click(function(){
	var wdWidth = document.body.scrollWidth;
	var wdHeight = document.body.scrollHeight;
	var x = event.pageX;
	var y = event.pageY;
	//alert(x + ‘ ‘ + y + ‘ ‘ + wdWidth + ‘ ‘ + wdHeight);
	draw(x,y);
})
</script>

<canvas id="yuanxing" width="1300px" height="1300px" style="position:absolute;top:0;left:0;">

</canvas>
<script type=text/javascript>
function draw(x,y,r){
	var r = arguments[3] || 20;
	var canvas=document.getElementById("yuanxing");
	var context=canvas.getContext("2d");
	context.fillStyle="blue";
	context.beginPath();
	context.arc(x,y,r,0,Math.PI*2,true); //Math.PI*2是JS计算方法,是圆
	context.closePath();
	context.fill();
}	
</script>

  

jquery canvas 用户点击记录

标签:

原文地址:http://www.cnblogs.com/bushe/p/4797759.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!