SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Sep 2008
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JS when hover off an element

    I am using JS to add a class to an element when it is hovered over.

    I also want to remove that class when the element is no longer hovered over.

    How do you do this?

    I also want to ensure it works on touch devices as well as with the mouse.

    I don't want to use jQuery (or any library).

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,682
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by johnsmith153 View Post
    I also want to ensure it works on touch devices as well as with the mouse.

    I don't want to use jQuery (or any library).
    With the touch devices (such as the ipad), some touch devices trigger the hover event when you first click, and then a second click on an item triggers the click event.

    Can you give more details of your needs in respect to the touch devices?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •