Quick Tip – jQuery Accordion for SharePoint 2010 Quick Launch


I thought that i would share a quick piece of code that you can use on your SharePoint sites to change the Quicklaunch from a standard view to an “accordion” style version using jQuery. The following code uses the OOTB v4.master so may not work if you have customised your design. (Changes to selectors should be all that would be required to get it working with your own design)

As you can see the jQuery is pretty simple. Firstly we need to get a reference to the jQuery library. (we have the version hosted with Microsoft. If you have a server which does not have internet access, you will need to download and reference a locally stored version of the library).

Next is to hide all of the children of the quicklaunch items so we are left with just the headings.

The Next step is to capture when the user hovers over the headings. When they do this they need to find the first anchor tag in the current <li> element and for the next element in the DOM (which is the UL) perform a slide toggle which will animate the accordion. When you hover the mouse off the item the alternate function is run the same code again which will reverse the accordion.

The final step is to add a count of the number of children into each of the headings. This will provide the end user with an indicator telling them an item as some hidden items. So with the current child <ul> we need to get the parent item (the heading) and get the text inside the anchor tag. To this anchor tag we append the number of items using the $this.children().length code block.

Finally you need to insert this into your masterpage using SharePoint Designer and thats it. I hope this quick tip was useful. I will hopefully be adding some more soon.

Please let me know how you get on.

I am the SharePoint Development Lead at ICS Solutions Ltd. As well as broad knowledge in SharePoint 2007, 2010 & 2013 my specialities lie with SharePoint Branding, WebPart Development and JQuery integration.

58 Comments on "Quick Tip – jQuery Accordion for SharePoint 2010 Quick Launch"

  1. to achieve this you would have to use cookies to save the state of the page or adjust the jquery to check the contents and if there is a child element found then expand the page. With different quick launches common on different sites i do not know if this solution would work?

  2. This is something that i am planning on doing soon but there are many things im trying to get completed. Watch this blog soon and you should have your solution.



  3. Mike Blair says:


    Is it possible to use jquery to set the width of the quick launch area? I am using metadata navigation pane which I resize manually but I’d like to set the width or have it automatically resize?


  4. Martha says:

    It is possible the subitems are displayed with hover, can be done with click, the client needs it in that way.

    THX for you possible response…

  5. Yes you can use jQuery. The width is defined in css which you also can override therefore don’t need to use jquery to accommodate this requirement

Trackbacks for this post

  1. How to do an accordion effect to quick launch menu with jQuery in Sharepoint 2010 « Paujas
  2. ??? ??????? (Arash Aghajani) : ??? ???? ? SharePoint 2013 ? ???????? ?????? ????? ?? ? ??? ?????? ????

Got something to say? Go for it!