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

    Join Date
    Mar 2002
    Location
    :::
    Posts
    10
    Rep Power
    0

    using css class to handle events


    is there a way I can do something similar to this?

    .myClass {
    onMouseOver: background: #000080
    onMouseOut: background: #ffffff
    }

    I would like to have css classes that encapsulate all of the event handlers that I need to reduce the redundant html in my pages.

    thanks,

    david
  2. #2
  3. |<.+#f@#+.&.|
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Mar 2002
    Location
    norway
    Posts
    3,009
    Rep Power
    1224
    in standard compliant browsers you can use the pseudo-class hover on any element.

    .myClass {
    background: #ffffff;
    }

    .myClass:hover {
    background: #000080;
    }

    ie.
    <p class="myClass">
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    :::
    Posts
    10
    Rep Power
    0
    Thanks for your reply.

    can handle events like onclick and blur in a similar manner?
  6. #4
  7. 7-1 underdog
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    14
    Rep Power
    0

    Unhappy CSS event handling


    I've been searching for the answer to this too, but it looks like unfortunately Microsoft Internet Explorer (my browser, and let's face it, almost everybody elses) can't handle :hover on anything but the <a> tag.

    This means if you're doing a page with multiple rollover images (a menu for instance) you will have to add a javascript "onMouseOver" event handler to every (yawn) image tag you want to react to mouseOver.

    Fortunately, IE offers HTC behaviors, which offer amazing functionality and event handling, but I'm a bit suspicious that Netscape and co might not be able to use them.

    Any high level users listening who can add to this?

    bob

IMN logo majestic logo threadwatch logo seochat tools logo