New accordion script for jQuery with cool features like, hash tag handling and smooth scroll to target toggler. You could add jQuery Easing and own callback functions.

Demo

Toggler 1

Squawfish saber-toothed blenny dory Atlantic cod sailfish bonnetmouth gopher rockfish tompot blenny freshwater flyingfish, Pacific lamprey deep sea eel. Sandbar shark shortnose chimaera sandperch sheepshead, parrotfish hammerhead shark gulper eel shark Reef triggerfish snake mudhead. Flabby whalefish deep sea eel--white shark Black scalyfin bigeye sea snail yellow bass. Bull shark; ladyfish, Rasbora, yellowfin cutthroat trout, "bullhead shark tiger shark Alaska blackfish," stoneroller minnow anchovy gray mullet sea chub. Ghost carp: vendace yellow-eye mullet Atlantic trout, "roughy rough pomfret snake mudhead emperor bream bichir chum salmon." Aruana sculpin yellowbanded perch garibaldi wrasse tubeshoulder, jewfish Atlantic silverside rice eel. Halfmoon climbing perch blue danio arrowtooth eel California smoothtongue Long-finned sand diver tui chub. Cardinalfish Black angelfish wallago molly spiny eel earthworm eel lake trout snake eel flagfin bristlenose catfish mahi-mahi. Black scabbardfish, ide Old World rivuline eelpout labyrinth fish flagfin, deepwater flathead shad eel. Capelin chum salmon flagfin speckled trout nurseryfish longnose dace. Tui chub panga platyfish cepalin Mexican golden trout shortnose chimaera Dolly Varden trout ladyfish elephant fish.

Toggler 2

Beaked salmon rough pomfret Sacramento blackfish, swordtail, yellow weaver, squarehead catfish goldfish bigscale fish. Dhufish trench goblin shark ribbon eel creek chub, Pacific cod killifish longfin dragonfish sand goby?"

Toggler 3

Pelagic cod Canthigaster rostrata New Zealand smelt, buri deep sea smelt loach catfish sandfish steelhead, poacher dace pikeperch swamp-eel! Ray telescopefish vendace, glowlight danio--panga smooth dogfish, ghost fish jawfish burrowing goby Indian mul Rainbowfish ballan wrasse. Seamoth, freshwater flyingfish driftwood catfish frogfish scabbard fish. Salmon Atlantic herring gar longnose chimaera Pacific herring longfin round herring. Asian carps cobia needlefish Rattail, hoki bull trout.

Download

Usage

The Plugin needs jQuery and must be included after the libary.

<!DOCTYPE html>
<html>
<head>
	[...]
	<script src="js/jquery-1.10.1.min.js"></script>
	<script src="js/jacc.js"></script>
	[...]
</head>
<body>
	[...]
	<div class="accordion">
		<h2 class="toggler">Toggler 1</h2>
		<div class="togglerBox">
			<!-- CONTENT OF TOGGLERBOX 1 -->
		</div>

		<h2 class="toggler">Toggler 2</h2>
		<div class="togglerBox">
			<!-- CONTENT OF TOGGLERBOX 2 -->
		</div>
	</div>
	[...]
</body>
</html>

Call the Plugin, the usual way in document ready function.

$(document).ready(function(){
  	$('.accordion').jacc();
});

Options

Key Default value Description
toggler '.toggler' CSS class of the clickable element whith point. (String)
togglerBox '.togglerBox' CSS class of the containers that slideUp/slideDown. (String).
openFirst false Opens first container of accordion on page load. (Boolean)
fxSpeed 500 Speed of slideUp/slideDown animation. (String).
animationSpeed 500 Specifies the animation speed of the page transitions. (Number)
easingIn '' Add an jQuery Easing effect to slideDown animation. (String)
easingOut '' Add an jQuery Easing effect to slideUp animation. (String)
focusSlide false Scroll document to current toggler. (Boolean)
focusOffset -10 Moves target point of scrolling document. (Number)
focusFxSpeed 500 Speed of document scroll animation. (Number)
onSlideUp   Callback parallel to slideUp animation. (Function)
slideComplete   Callback after slideDown animation completes. (Function)

Changelog

  • Version 1
    • new: if hash starst with '#topic:' toggler with id = hash name is active
    • new: togglerBox with hash target inside would open on start
    • new: add compressed version of scipt (jacc.min.js)
    • fix: change position of ending (jQuery)
  • Version 0.3 - fix identifier problem with ops.this: changed to ops._this
  • Version 0.2 - Add some new functions (alpha)
  • Version 0.1 - Startbuild of script (alpha)

Licence

The plugin jacc is under MIT licence and GNU licence.
Copyright © 2014 Konrad Rolof