views:

72

answers:

2

I have written a few lines of jQuery to animate a div to the left/right depending on mouse movements

 $(".galleryNav").mousemove(function(e){
  $("#status").html(e.pageX +', '+e.pageY);

  if(e.pageX > 1100 && e.pageX < 1170){
   $(".galleryNav").animate({marginLeft:"-60px"},{queue: false, duration: 450});
  }

  if(e.pageX > 410 && e.pageX < 465){
   $(".galleryNav").animate({marginLeft:"10px"},{queue: false, duration: 450});
  }
 });

it works fine in firefox, but nothing happens in chrome, safari or IE.

Any suggestions?

A: 

Works fine in chrome http://jsfiddle.net/x9eZY/ maybe the problem is elsewhere? have you encapsulated your script in $(function(){}) like so:

$(function(){
    $(".galleryNav").mousemove(function(e){
      $("#status").html(e.pageX +', '+e.pageY);

      if(e.pageX > 1100 && e.pageX < 1170){
       $(".galleryNav").animate({marginLeft:"-60px"},{queue: false, duration: 450});
      }

      if(e.pageX > 410 && e.pageX < 465){
       $(".galleryNav").animate({marginLeft:"10px"},{queue: false, duration: 450});
      }
    });
})  
​
Kristoffer S Hansen
yes its all within $(document).ready(function() { });
bell
A: 

To me it works fine withe jQuery 1.4.2 + UI 8. Check you CSS.

jmav