How can I use jQuery to follow the cursor with a div?
<p>I have a div in the shape of a circle that follows your mouse using Javascript, but I want it to stop when it hits the edge of a container div. How would I do that? Here is the Javascript im using:</p>

<pre><code>var mouseX = 0, mouseY = 0;
$(document).mousemove(function(e){
mouseX = e.pageX;
mouseY = e.pageY;
});

// cache the selector
var follower = $("#follower");
var xp = 0, yp = 0;
var loop = setInterval(function(){
// change 12 to alter damping higher is slower
xp += (mouseX - xp) / 12;
yp += (mouseY - yp) / 12;
follower.css({left:xp, top:yp});

}, 30);
</code></pre>

<p>and here is everything else I have so far: <a href="http://jsfiddle.net/t_man/JUknN/9/" rel="nofollow">jsFiddle</a></p>

<p>Please help, and thanks!</p>
