/    Sign up×
Community /Pin to ProfileBookmark

How do I make an image follow the mouse?

Hello I am haveing a little bit of trouble. I need to make a web page where an image follows your mouse when you move it around. The problem is I don’t know where to start ? I am pretty sure I know how too find the position of the mouse but I don’t know how to make an event fire evenytime the mouse is moved and I don’t know how too display an image near it. If anyone could help it would be greatly appriated ?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@KorJul 29.2006 — 
  • 1. get the mouse position

    use [B]onmousemove[/B] event aplied to the body (or to the document). Take care, IE and Moz uses different syntax to capture the events and to return the mouse position.


  • 2. set the object's position according to the mouse position
  • Copy linkTweet thisAlerts:
    @LuinnarauthorJul 29.2006 — Ok thanks for the help ?
    Copy linkTweet thisAlerts:
    @felgallJul 29.2006 — I have a complete script to do this at http://javascript.about.com/library/blfollow1.htm
    ×

    Success!

    Help @Luinnar spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.19,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...