JQUERY: div following the mouse

Hi Experts,

I have this code:
$(document).ready(function(){
var p = $(".external");
var offset = p.offset();

$('.external').mousemove(function(e){
      var xpos =  e.pageY - offset.top;
      $('.external-follow').html(xpos);
        $('.external-follow').animate({top: '+xpos'}, 1000, function() {});       
   });

});

Where I am trying to get the external-follow to move with the mouse. The coordinates are correct in the .html function but it wont anmimate...

Any ideas?
Thanks in advance!
maccaj51Asked:
Who is Participating?
 
leakim971PluritechnicianCommented:
0
 
maccaj51Author Commented:
ive updated the script to this... but it doesnt work very well at all...

Any advice?

$(document).ready(function(){
var p = $(".external");
var offset = p.offset();

$('.external').mousemove(function(e){
      var xpos =  e.pageY - offset.top;
      $('.external-follow').html(xpos);
        $('.external-follow').stop().animate({top: +xpos}, 1000, function() {});       
   });

});
0
 
maccaj51Author Commented:
Many Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.