#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    The Netherlands
    Posts
    14
    Rep Power
    0

    Custom cursor on mouseover?


    Good day,

    So, as the title says i would like to change my cursor when i mouseover a div, everything i could think of was this:
    Code:
    <div onmouseover="this.style.cursor='hand'">Text</div>
    But this doesn't work.. Does anyone know how i can do this? Thanks!
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    The "hand" cursor style is actually called 'pointer'. In modern browsers you can do this with CSS:
    Code:
    div:hover {
      cursor: pointer;
    }
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,124
    Rep Power
    4303
    You don't need a hover style for that though. The "cursor" property only applies when your cursor is over the element anyway.
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    The Netherlands
    Posts
    14
    Rep Power
    0

    Post


    Originally Posted by E-Oreo
    The "hand" cursor style is actually called 'pointer'. In modern browsers you can do this with CSS:
    Code:
    div:hover {
      cursor: pointer;
    }
    Oh, thanks for the help but i dropped the wrong code by accident.. Sorry for that.
    The actual code was this:

    Code:
    <div onmouseover="this.style.cursor='mycursor.cur'">Text</div>
    Sory for the mistake :$
  8. #5
  9. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    If mycursor.cur is a reference to a JavaScript object it shouldn't have single quotes around it.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo