SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,097
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Accordion Menu a:not(:first)

    I have a simple accordion menu (5 menu items in total), where only the second menu Item has a sub menu. So I need a way to target the first, third, fourth and fifth menu items to make them work direct links going straight to another page.

    So far I have this:
    Code:
    	$(document).ready(function () {
    		$( "dd" ).hide();
    		$( "dt a:not(:first)" ).click(function(){
    		
    			$( "dd:visible" ).slideUp( "slow" );
    			$( this ).parent().next().slideDown( "slow" );
    			return false;
    		});
    	});
    Where because of $( "dt a:not( :first )" ).click(function(){ the first menu item is reacting as a normal link, but I have no Idea how to target the third, forth and fifth as well. Please advise


    Thank you in advance
    “Good artists copy, great artists steal” (Pablo Picasso - 1934)

  2. #2
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,097
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi all. I tried to add extra functions like:
    Code:
    $( "dt a:not(:third)" ).click(function(){
    });
    I don't get any errors but it isn't working either. I not even know if third is valid to use. I've been searchin on Google but couldn't find anything back. Please advise where to look for?

    Thank you again
    “Good artists copy, great artists steal” (Pablo Picasso - 1934)

  3. #3
    SitePoint Addict sdleihssirhc's Avatar
    Join Date
    Feb 2009
    Posts
    387
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    It looks like the accordion stuff is in your click listener, and you're trying to only apply it to the second link. Is that correct? If so, you only need to use the eq function to do what you want:

    Code JavaScript:
    $('dt a').eq(1).click(function () {
        /* do accordion stuff here */
    });
    I'm the web overlord for Graphic Business Systems

  4. #4
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,097
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi sdleihssirhc, does that mean I can leave this:
    Code:
    $( "dt a:not(:first)" ).click(function(){
    out all together?y?

    Thank you in advance.
    “Good artists copy, great artists steal” (Pablo Picasso - 1934)

  5. #5
    SitePoint Addict sdleihssirhc's Avatar
    Join Date
    Feb 2009
    Posts
    387
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    It certainly does... I think. I'm pretty sure. Does it break if you take it out (and put it my replacement)?
    I'm the web overlord for Graphic Business Systems

  6. #6
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,097
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi sdleihssirhc

    That works like a charm. Thank you so much.
    “Good artists copy, great artists steal” (Pablo Picasso - 1934)


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
  •