I need rotate arrow with Jquery-rotate, but i dont know cursor's angle :( I try calculate it, but script not work.
I want result like this http://www.lonhosford.com/content/html5/canvas/rotate_to_mouse.html
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
function diff(x, y) {
var a = (x * Math.PI / 180) - Math.PI;
var b = (y * Math.PI / 180) - Math.PI;
return Math.atan2(Math.sin(b - a), Math.cos(b - a)) * (180 / Math.PI);
}
$('body').mousemove(function(e){
var x = e.pageX;
var y = e.pageY;
var myAngle = diff(x, y);
$("#image").rotate(myAngle);
});
});
//]]>
</script>