JQuery Accordion using JQuery UI Example
Today, i am going to give you simple example code of accordion usign jquery ui. Sometimes we need to add quick without bootstrap and other jquery plugin.
So, you can learn how to add simple jquery accordion in your php or other framework project. Here is a simple four section with it's content so you can understand simply.
So, let's see bellow example for jquery accordion.
Example:
<html lang="en">
<head>
<title>Jquery accordion examples demo</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
</head>
<body>
<div id="myaccordion">
<!-- accordion 1 -->
<h2>My Accordion 1</h2>
<div>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<!-- accordion 2 -->
<h2>My Accordion 2</h2>
<div>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<!-- accordion 3 -->
<h2>My Accordion 3</h2>
<div>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<!-- accordion 4 -->
<h2>My Accordion 4</h2>
<div>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$( "#myaccordion" ).accordion();
});
</script>
</body>
</html>
You can check demo from bellow link.
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Remove Empty or Null Values from JSON using JQuery?
- How to Check If Key Exists in JSON Object using JQuery?
- PHP Ajax Drag and Drop Sorting Table Rows Example
- How to Remove All Spaces from String in JQuery?
- PHP MySQL DataTables Server-side Processing Example
- How to Change Date Format in JQuery?
- How to Add Custom Validation for Image File Upload in Summernote?
- JQuery Prevent Submit Form on Enter Key Except Textarea Example
- JQuery Tooltip Example using JQuery UI Plugin
- AngularJS Tooltip using UI Bootstrap tpls HTML Example
- JQuery Datepicker Example using JQuery UI JS
- How to access PHP variables in JQuery?
- Autocomplete with Images and Custom HTML Code in Jquery UI?