Javascript is affecting all <ul> just want it to affect one

Discussion in 'JavaScript' started by Hot Chile Grrr, Oct 13, 2009.

  1. #1
    I am using an accordion style menu that is meant to smooth scroll to certain anchors. This works. But the <ul> parameters set in the javascript make all my <ul> have those properties.

    Is there a way to separate them by class or id?

    I'm a newbie.

    Here's the link to the issue:

    http://www.anactofwill.com/help/
     
    Hot Chile Grrr, Oct 13, 2009 IP
  2. rags02

    rags02 Member

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #2
    Give the the <a> anchors within the applicable <li> a class like "aItem" and alter your jQuery:

    $("ul li a.aItem").hover(
          function(){
            $(lastBlock).animate({width: minWidth+"px"}, { queue:false, duration:400 });
        $(this).animate({width: maxWidth+"px"}, { queue:false, duration:400});
        lastBlock = this;
          }
        );
    Code (markup):
    Not tested... should work.
     
    rags02, Oct 13, 2009 IP
  3. Hot Chile Grrr

    Hot Chile Grrr Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    @ rags02

    Did like you said and worked like a charm. Hopefully this will test well in the browsers. Thank you.
     
    Hot Chile Grrr, Oct 13, 2009 IP