Accordion
Accordion is a super simple and light weight accordion menu plugin for Jquery. Accordion’s sub 1kb footprint makes it both easy to use and fast to load. The demo explains it all.
How to use Accordion
- <ul>
- <li>
- <a href="#america">America</a>
- <ul>
- <li>
- <a href="#america-newyork">New York</a>
- <div>Information about New York</div>
- </li>
- <li>
- <a href="#america-sanfransisco">San Fransisco</a>
- <div>Information about San Fransisco</div>
- </li>
- </ul>
- </li>
- <li>
- <a href="#antarctica">Antarctica</a>
- <div>Information about Antarctica</div>
- </li>
- </ul>
When you have created the necessary html code you need to include the javascript file with the plugin and call the accordion method. See the demo for a more detailed example.
- <script type="text/javascript">
- $( selector ).accordion();
- </script>
How to link to a level inside the accordion
Notice the href-attributes on each a-element. If you in the html code example above create a link to #america-newyork and click it the accordion will open up ‘New York’ and all it’s parents.
How to open a panel on load
Set the li classname to “current” and it will be open when the page loads.
How to open a panel via Javascript
You can activate nodes via Javascript by using the “activate-node” trigger.
- <script type="text/javascript">
- $('a[href=#antarctica]').trigger('activate-node');
- </script>
| Version | Changes |
|---|---|
| 1.4 | Fixed a bug regarding “current” class and added activate-node trigger. |
| 1.3 | Refactored code and fix a bug with images inside a tags |
| 1.2.2 | Added functionality to open a panel on load by specifying the li class to “current”. |
| 1.2.1 | Fixed an error that occurred when no hash was set. |
| 1.2 | It is now possible to link to a specific level using a hash |
| 1.1 | Fixed an issue causing the accordion to stop working if you applied the accordion method twice on the same element. |
3 days ago
Wow! I don’t even remember anymore how I managed before this new awesome boilerstrap. http://t.co/bWzwqVf2
3 days ago
If you like coding and competing and want to see Stockholm at its best; Checkout Escape from /dev/null – DICE edition. http://t.co/0SapzZxz
4 days ago
Last night @soe, @tussetor and I won #sthlmstartuphack and the best trophy ever. http://t.co/CJ15cNml
4 days ago
Thanks @kalasjocke, @martinaelm, @javve for a super fun event. Thanks @soe, @tussetor for being awesome teammates. #sthlmstartuphack
5 days ago
Going where none has gone before and pushing the boundaries of what has been called done. Mine, @soe, @tussetor #SthlmStartupHack app ≈Done
6 days ago
Selected map, data and chart tools. http://t.co/I7l6qq4O (via @VirUZI) So much joy in one single place!
7 days ago
How can Comic Sans make people buy your app? http://t.co/KYLGeIW2