SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JQuery Hover Question

    Here's my problem:

    I have a css menu with two links using the id #print and #online. Below the menu I have a group of 2 kinds of image links with the classes .print-images and .online-images.

    What I want to happen is when a user moves their mouse over an image with the .print-images or .online-images class it activates the hover state of the corresponding menu item #print or #online.

    Thanks for any help

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,702
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    If you place the image inside the link, you can then use css to reposition the image which will then ensure that the links hover when you hover over the image.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's not quiet what I mean.

    I already have hover states setup in the css what I want to happen is for the state of the menu item #print to change when a user mouses over any image with the class .print-image.

    So while the mouse is over the .print-image in the body of the page the hover state is activated on the menu item print in the top navigation.

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Like this?
    Code:
    $("img.print-images").hover(
        function() {
            $("#print").addClass("hoverstyle");
        }
      , function() {
            $("#print").removeClass("hoverstyle");
        }
    );


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
  •