Turn the accordion panel to plain html in JavaScript

Description

The following code shows how to turn the accordion panel to plain html.

Example


<!--   w  w w  .j ava2 s  . c om-->

<!doctype html>
<html lang="en">
<head>
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" rel="stylesheet" />

<script type="text/javascript">
$(function() {

//turn specified element into an accordion
$("#myAccordion").accordion();

//attach click hander to button
$("#accordionKiller").click(function() {

//destroy the accordion
$("#myAccordion").accordion("destroy");
});
});
</script>
</head>
<body>
<button id="accordionKiller">Kill it!</button>
<div id="myAccordion">
<h3><a href="#">Section 1</a></h3>
<div>
<p>P1</p>
</div>
<h3><a href="#">Section 2</a></h3>
<div>
<p>P2</p>
</div>
<h3><a id="header3" href="#">Section 3</a></h3>
<div>
<p>P3</p>
<ul>
<li>List item one</li>
<li>List item two</li>
<li>List item three</li>
</ul>
</div>
<h3><a href="#">Section 4</a></h3>
<div>
<p>P4</p>
</div>
</body>
</html>

Click to view the demo

The code above generates the following result.

Turn the accordion panel to plain html in JavaScript