Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript [Solved] Affecting non-hovered items

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #28570
    dcp3450
    Participant

    I want to only affect non-hovered items in a list. For example:

    Code:
    • List items
    • List items
    • List items
    • List items
    • List items

    I want all items full opacity but when I hover over an items the other drop to .5 opacity. I know how to affect one’s I’m currently hovered over. However, I want the opposite effect.

    #73605
    Chris Coyier
    Keymaster
    Code:
    $(function() {

    $(“ul”).delegate(“li”, “mouseover mouseout”, function(e) {

    $(“ul li”).not(this).css(“opacity”, e.type == ‘mouseover’ ? 0.5 : 1);

    });

    });

    #73606
    dcp3450
    Participant

    Awesome! Thanks Chris. I could have sworn you covered this in an article once but I couldn’t find it.

    #73638
    dcp3450
    Participant

    Chris,

    I used:

    Code:
    $(“ul”).delegate(“li”, “mouseover mouseout”, function(e) {
    $(“ul li”).not(this).css(“opacity”, e.type == ‘mouseover’ ? 0.5 : 1);
    });

    and

    Code:
    $(“li”).hover(function() {
    $(“li”).not(this).css(“opacity”, 0.5);
    }, function() {
    $(“li”).not(this).css(“opacity”, 1);
    });

    both work great, however, IE freaks the text out and changes their alignment and size. The text even gets choppy.
    http://www.chattahoocheetech.edu/sandbox/newctc/sports/crosscountry/

    any ideas?

    #73664
    davmillar
    Member

    Wouldn’t something like this work? Tested it quickly using Firebug in Firefox 3.5.5 on Win XP.

    Code:
    ul {opacity:1;}
    ul:hover li {opacity:0.5;}
    ul li:hover {opacity:1;}
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.