<html>
<head>
<style>
.container {
background-color: black;
color: white;
cursor: pointer;
padding: 15px;
width: 16%;
border: none;
font-size: 15px;
}
.active, .container:hover {
background-color: orange;
color: black;
}
.Data {
padding: 0 18px;
display: none;
background-color: white;
overflow: hidden;
font-size:35px;
}
</style>
</head>
<body>
<h2>Accordion</h2>
<p>Accordions are useful when you want to hide and further show a large amount of content:</p>
<button class="container">Click Me!</button>
<div class="Data">
<p>Hello TutorialsLink!</p>
</div>
<script>
var a= document.getElementsByClassName("container");
var i;
for (i = 0; i < a.length; i++) {
a[i].addEventListener("click", function() {
this.classList.toggle("active");
var data = this.nextElementSibling;
if (data.style.display === "block") {
data.style.display = "none";
} else {
data.style.display = "block";
}
});
}
</script>
</body>
</html>Program to implement Accordion.

Nitin Pandit
With over 10 years of vast development experience with different technologies, Nitin Pandit is Microsoft certified Most Valued Professional (Microsoft MVP) with a rich skillset that includes developing and managing IT/Web-based applications in different technologies, such as – C#.NET, ADO.NET, LINQ to SQL, WCF, and ASP.NET 2.0/3.x/4.0, WCF, WPF, MVC 5.0 (Razor), and Silverlight, along with client-side programming techniques, like jQuery and AngularJS. Nitin possesses a Master’s degree in Computer Science and has been actively contributing to the development community for its betterment. He has written more than 100 blogs/articles and 3 eBooks on different technologies to help improve the knowledge of young technology professionals. He has trained more than one lakh students and professionals, as a speaker in workshops and AppFests, conducted in more than 25 universities in North India.
