jQuery move divs according to mouse position
i got a little Problem with jQuery, maybe you guys can help me. Here's the
HTML Markup in jfiddle for better understanding:
jsfiddle
I'd like to have the div called #move_me to move either to the right or to
the left side within the #content_wrapper according to the mouse position
inside #content_wrapper.
basically what i want is: if i move my cursor inside the #content_wrapper
div to the right then the #move_me div should move to the left to see
content2 div, when i move to the left the #move_me div should move to the
right to see content1 div..
any ideas guys? i tried to get it to work with mousemove and pageXoffset
but i didnt get it to work... any help is appreciated !
something like this:
$('#content_wrapper').mousemove(function(e){
var x = e.pageX - this.parentoffsetLeft;
$('#move_me').css({'left': x});
});
No comments:
Post a Comment