Hi, In this blog we are going to create a custom accordion using jquery. As we all know that we can easily adapt the jQuery UI’s accordion, but what about creating a custom one.
So, First of all we will start by including our Html Structure, as this structure is basic for the accordions. Here comes our Html part.
Heading 1
Heading 1 TextHeading 2
Heading 2 TextHeading 3
Heading 3 Text
After that we will include some css, you can make your custom styles as I am just using the some basic one’s. Here comes our css part.
h4{cursor: pointer; } div{display: none; } .active{color: #ccc; }
And after that last but not the least we will add some jquery which makes our accordion comes alive. Here comes our jquery code.
$(function(){ $("h4").click(function(){ $(this).next().slideDown("fast"); $("div").not($(this).next()).slideUp("fast"); $("h4").removeClass("active"); $(this).addClass("active"); }); });
In this way we can create a custom according with the help of jquery.
Thanks
More From Oodles
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Gaurav Arora
Gaurav is an experienced UI developer with experience and capabilities to build compelling UI's for Web and Mobile Applications.