JQuery Accordion

0
30

Accordions are space savers in web designs, jquery UI have a builtin Accordion which can be bring in lesser lines of code

Import JQuery UI CSS

<link rel=”stylesheet” href=”http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css” />

Next Bring JQuery Libraries

<script src=”http://code.jquery.com/jquery-1.9.1.js”></script>
<script src=”http://code.jquery.com/ui/1.10.3/jquery-ui.js”></script>

Now the Script Part

<script>
$(
function()
{
$( “#accordion” ).accordion();
}
);
</script>

Thatz it Now the Markup

<body>

<div id=”accordion”>
<h3>First Heading</h3>
<div>
<p>
Some text for Heading 1
</p>
</div>
<h3>Section 2</h3>
<div>
<p>
Some Text for Heading 2
</p>
</div>
</div>

</body>

Place the dividers and <p> s exactly as in the code. Done Accordion is ready

Here is the Entire markup

<html lang=”en”>
<head>
<meta charset=”utf-8″ />
<title>jQuery UI Accordion – Default functionality</title>
<link rel=”stylesheet” href=”http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css” />
<script src=”http://code.jquery.com/jquery-1.9.1.js”></script>
<script src=”http://code.jquery.com/ui/1.10.3/jquery-ui.js”></script>

<script>
$(
function()
{
$( “#accordion” ).accordion();
}
);
</script>
</head>
<body>

<div id=”accordion”>
<h3>First Heading</h3>
<div>
<p>
Some text for Heading 1
</p>
</div>
<h3>Section 2</h3>
<div>
<p>
Some Text for Heading 2
</p>
</div>
</div>

</body>
</html>

LEAVE A REPLY

Please enter your comment!
Please enter your name here