Cool And Simple Vertical Accordian Menu Using jQuery CSS and HTML
Last Updated : Apr 15, 2022
Accordion menu is a great way to display content whenever there is less space in web page user can view all the content simply by clicking on heading tab.
In this tutorial we will create a simple and cool Vertical Accordion Menu using jQuery,CSS and HTML. You may also like html5 toggle menu.
CHECK OUT THIS TUTORIAL LIVE DEMO →
To create a Vertical Accordion Menu it takes only two steps:-
- Make a HTML file and define markup and script for Accordion Menu
- Make a CSS file and define styling for Accordion Menu
Step 1. Make a HTML file and define markup and script for Accordion Menu
We make a HTML file and save it with a name menu.html
<html> <head> <link rel="stylesheet" type="text/css" href="menu_style.css"> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> function paragraph(id) { $("#"+id+"-para").slideToggle(); } </script> </head> <body> <h1>Accordion Menu Using jQuery And CSS</h1> <div> <li id="li-one" onclick="paragraph(this.id);">First Para Info</li> <p id="li-one-para"> This is just an example of Simple Accordion This is just an example of Simple Accordion This is just an example of Simple Accordion </p> <li id="li-two" onclick="paragraph(this.id);">Second Para Info</li> <p id="li-two-para"> This is just an example of Simple Accordion This is just an example of Simple Accordion This is just an example of Simple Accordion </p> <li id="li-third" onclick="paragraph(this.id);">Third Para Info</li> <p id="li-third-para"> This is just an example of Simple Accordion This is just an example of Simple Accordion This is just an example of Simple Accordion </p> <li id="li-fourth" onclick="paragraph(this.id);">Third Para Info</li> <p id="li-fourth-para"> This is just an example of Simple Accordion This is just an example of Simple Accordion This is just an example of Simple Accordion </p> </div> </body> </html>
In this step we define all the markups for Accordion Menu and we use jQuery slideToggle() function to show and hide the content with animation. You may also like floating navigation menu.
Step 2. Make a CSS file and define styling for Accordion Menu
We make a CSS file and save it with name menu_style.css.
body { background-color:#CED8F6; font-family:helvetica; } h1 { text-align:center; color:blue; margin-top:100px; } div { margin:0px auto; width:250px; } div li { background-color:#2E64FE; font-size:20px; color:white; padding:10px; cursor:pointer; border:1px solid #A4A4A4; } div p { display:none; background-color:#F2F2F2; color:#585858; font-size:18px; margin:0px; padding:10px; }
Thats all, this is how to create a Accordion Menu using jQuery,CSS and HTML. You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.
Latest Tutorials
- Create Animated Skill Bar Using jQuery, HTML And CSS
- Simple And Best Responsive Web Design Using CSS Part 2
- Show Button On Hover Using HTML And CSS
- Material Design Login Form Using jQuery And CSS
- Animated Progress Bar Using jQuery And CSS
- Dynamic Drop Down Menu Using jQuery, Ajax, PHP And MySQL
- Get Website Statistics Using PHP, jQuery And MySQL
- HTML5 Login And Signup Form With Animation Using jQuery
- Facebook Style Homepage Design Using HTML And CSS
- View Webpage In Fullscreen Using jQuery