No public Twitter messages.

Exactly How to Create a Custom jQuery Accordion

Yesterday, I saw that NETTUTS was looking for another staff writer. I figured that I would give it a shot and write a tutorial about creating a custom jQuery accordion (just like the one on the sidebar of my website). Well what do you know, they published it.

Share This:
  • del.icio.us
  • Digg
  • Twitter
  • Facebook
  • StumbleUpon
  • Google Bookmarks
  • NewsVine
  • Technorati
  • Reddit
  • LinkedIn

RSS feed of comments for this entry

  1. congratulations! i’m totally saving the article for future use.

  2. Congrats!

    AEA 2010!

  3. Fantastic, very usefull

  4. Dope article, your version is lighter and will definitely get integrated into my bog redesign.

  5. @ThaClown & Cam-
    Awesome, glad you guys enjoyed it.

  6. I tried to modify your script to have a multi-level Jquery Accordion menu (3 levels) and keep my window active when I click on the link like this example
    http://berndmatzner.de/jquery/hoveraccordion/
    but I fail. Any help ?

  7. @cosinus-
    What wasn’t working? You will definitely have to modify the code some. Do you have an example that shows how far you got?

  8. Collapsible Message Panels

    $(document).ready(function(){
    	last=null;
    	$(".msg_body").hide();
    	$(".sub_msg_body").hide();
    
    	$(".msg_head").click(function(){
    		$(this).next(".msg_body").slideToggle(600).siblings(".msg_body:visible").slideUp("600");
    		$(this).toggleClass("active");
    	    $(this).siblings(".msg_head").removeClass("active");
    	});
    
    	$(".sub_head").click(function(){
    		$(this).next(".sub_msg_body").slideToggle(600);
    		if ( $(this).filter(':contains(Sub-Header-1)') )
    		 window.open ("http://www.google.com");
    	});	
    
    	$(".msg_body .link,.sub_msg_body .link").click(function(){
    	    $(last).css({'background-color':'#CDC8B1', 'border-left': '5px solid #ccc'});
    		$(this).css({'background-color':'#ffe', 'border-left': '5px solid #ccc'});
    		last=this;
    	});	
    
    });
    body {
    	margin: 10px auto;
    	width: 570px;
    	font: 75%/120% Verdana,Arial, Helvetica, sans-serif;
    }
    .msg_list {
    	margin: 0px;
    	padding: 0px;
    	width: 383px;
    }
    p {
    	padding: 0 0 1em;
    }
    .msg_head {
    	padding: 5px 10px;
    	cursor: pointer;
    	position: relative;
    	background-color:#FFCCCC;
    	margin:1px;
    }
    .msg_body {
    	padding: 5px 10px 15px;
    	background-color:#F4F4F8;
    }
    .sub_head {
    	padding: 5px 10px;
    	cursor: pointer;
    	background-color:#7AC5CD;
    }
    .sub_msg_body {
    	padding: 5px 10px 15px;
    	background-color:#F4F4F8;
    }
    .msg_body .link{
    	padding: 5px 10px;
    	cursor: pointer;
    	background-color:#7AC5CD;
    }
    .sub_msg_body .link{
    	padding: 5px 10px;
    	cursor: pointer;
    	background-color:#CDC8B1;
    }
    a {text-decoration:none; }
    .active {background-color:#A2B5CD;}

    Click on the each news head to toggle

    Header-1
    link-1
    Sub-Header-1
    link-1
    link-2
    link-2

    Header-2

    link-1
    link-2

Speak Your Mind

* Denotes Required Field

  1. To post code snippets, use <pre><code>YOUR CODE HERE</code></pre>
Me, Trevor Davis. My blue steel face…

Hi, I’m Trevor Davis

I’m a 25 year old Front-End Developer living in Arlington, VA. I work full-time at Viget Labs and freelance on the side.

I specialize in CSS, HTML, jQuery, WordPress & ExpressionEngine. See more of my work, and then hire me.

Recent Work

  • 4th District IBEW Health Fund
  • Employers Council on Flexible Compensation
  • Monica Davis
  • The National Christmas Tree
  • Matrix Group International
  • The MatriX Files
  • Wireless Career
  • George Washington Wired
  • Direct Selling 411
  • Makeup Bizz
  • InstallNET
  • National Park Foundation
See More of My Work

Asides