This tutorial describes how to install the default horizontal theme, installation of other themes is identical.
First of all it's necessary to include all required files into your website.
Note: It's important to include .js files in this order: jQuery, jQuery easing plugin (optional), jAccordion plugin, otherwise you may experience unexpected behaviour.
<!--CSS file containing a theme of jAccordion--> <link type="text/css" href="jAccordion/default.css" rel="stylesheet"> <!--jQuery - minified version, use version 1.4.3 or newer (except 1.8.0)--> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <!--jQuery easing plugin - minified version, no need to insert this script if you use default easing metod --> <script type="text/javascript" src="jAccordion/jquery.easing.1.3.min.js"></script> <!--jAccordion - minified version--> <script type="text/javascript" src="jAccordion/jquery.jAccordion-1.2.6.min.js" ></script>
The next step is to add HTML code to body section of your website.
Note : jAccordion allows you to use different types of markup, you can choose one of those mentioned in the summary below.
Note #2: You can remove class noJS from parent container if you don't care about JS fallback.
Example of jAccordion markup using div elements:
<div class="accordion noJS"> <div class="jAccordion-slidesWrapper"> <div class="jAccordion-slide"><!-- Content of slide 1 --></div> <div class="jAccordion-slide"><!-- Content of slide2 --></div> <div class="jAccordion-slide"><!-- Content of slide3 --></div> <div class="jAccordion-slide"><!-- Content of slide4 --></div> <!-- Place here as many slides as you want --> </div> </div>
Example of jAccordion markup using unordered list:
<div class="accordion noJS"> <ul class="jAccordion-slidesWrapper"> <li class="jAccordion-slide"><!-- Content of slide 1 --></li> <li class="jAccordion-slide"><!-- Content of slide 2 --></li> <li class="jAccordion-slide"><!-- Content of slide 3 --></li> <li class="jAccordion-slide"><!-- Content of slide 4 --></li> <!-- Place here as many slides as you want --> </ul> </div>
Example of jAccordion markup using definition list:
<div class="accordion noJS"> <dl class="jAccordion-slidesWrapper"> <dd class="jAccordion-slide"><!-- Content of slide 1 --></dd> <dd class="jAccordion-slide"><!-- Content of slide 2 --></dd> <dd class="jAccordion-slide"><!-- Content of slide 3 --></dd> <dd class="jAccordion-slide"><!-- Content of slide 4 --></dd> <!-- Place here as many slides as you want --> </dl> </div>
You can even use HTML5 elements such as section but keep in mind that older browsers doesn't support HTML5, thus jAccordion won't work correctly in those browsers (you can use html5shiv to make it work in the older browsers):
<div class="accordion noJS"> <div class="jAccordion-slidesWrapper"> <section class="jAccordion-slide"><!-- Content of slide 1 --></section> <section class="jAccordion-slide"><!-- Content of slide 2 --></section> <section class="jAccordion-slide"><!-- Content of slide 3 --></section> <section class="jAccordion-slide"><!-- Content of slide 4 --></section> <!-- Place here as many slides as you want --> </div> </div>
The next step is to set size of jAccordion, which is done via .css file. Default size of the horizontal theme is 980x380px so you can skip this section if you are satisfied with these values.
The next step is activation of the plugin.
Example of a configuration section:
<script type="text/javascript"> // Avoid conflict with other libraries jQuery(document).ready(function( $ ) { $('.accordion').jAccordion({ activeSlideSize : 700, onReady : function() { $('.preloader', this.$accordion).remove(); } }); }); </script>
Since jAccordion v1.2.6 there is a possibility to specify options via data attributes, which is useful if you want to create multiple similar instances of jAccordion on one page. You can specify the identical options in the configuration section and the options that differs can be specified via data attributes of every instance.
<script type="text/javascript"> // Avoid conflict with other libraries jQuery(document).ready(function( $ ) { $('.accordion').jAccordion({ // Here comes options identical for all instances }); }); </script> <!-- Eeach accordion has different option transitionSpeed --> <div class="accordion noJS" data-options='{"transitionSpeed": 5000}'><!-- Content of accordion --></div> <div class="accordion noJS" data-options='{"transitionSpeed": 1000}'><!-- Content of accordion --></div>