Step 1:- It's is very simple HTML and basic jQuery code.This can be done in 2 specific ways:
WAY 1:- a simple jquery Accodion
Demo/index.html
<!DOCTYPE html>
<html>
<head>
<title>a simple jquery Accodion</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<ul id="accodion">
<li><a href="#!">what are you doing 1</a>
<p>Many users already have downloaded jQuery from Google or Microsoft when visiting another site. As a result, it will be loaded from cache when they visit your site, which leads to faster loading time. Also, most CDN's will make sure that once a user requests a file from it, it will be served from the server closest to them, which also leads to faster loading time.</p>
</li>
<li><a href="#!">what are you doing 2</a>
<p>Many users already have downloaded jQuery from Google or Microsoft when visiting another site. As a result, it will be loaded from cache when they visit your site, which leads to faster loading time. Also, most CDN's will make sure that once a user requests a file from it, it will be served from the server closest to them, which also leads to faster loading time.</p>
</li>
<li><a href="#!">what are you doing 3</a>
<p>Many users already have downloaded jQuery from Google or Microsoft when visiting another site. As a result, it will be loaded from cache when they visit your site, which leads to faster loading time. Also, most CDN's will make sure that once a user requests a file from it, it will be served from the server closest to them, which also leads to faster loading time.</p>
</li>
<li><a href="#!">what are you doing 4</a>
<p>Many users already have downloaded jQuery from Google or Microsoft when visiting another site. As a result, it will be loaded from cache when they visit your site, which leads to faster loading time. Also, most CDN's will make sure that once a user requests a file from it, it will be served from the server closest to them, which also leads to faster loading time.</p>
</li>
<li><a href="#!">what are you doing 5</a>
<p>Many users already have downloaded jQuery from Google or Microsoft when visiting another site. As a result, it will be loaded from cache when they visit your site, which leads to faster loading time. Also, most CDN's will make sure that once a user requests a file from it, it will be served from the server closest to them, which also leads to faster loading time.</p>
</li>
</ul>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript"> $(document).on('click','ul#accodion>li>a',function(){ // alert(1);
$(this).siblings('p').stop().slideToggle(); $(this).closest('li').siblings('li').find('p').stop().slideUp(); });</script>
</body>
</html>
Demo/style.css
html,body{
padding: 0;
margin: 0;
width: 100%
height:100%;
background-color: #f5f5f5;
}
ol,ul{
margin: 0;
padding: 0;
list-style: none;
}
a{
text-decoration: none;
}
#wrapper{
width: 100%;
max-width: 960px;
border: 1px solid #ccc;
margin: 0 auto;
background-color: #fff;
padding: 20px;
box-sizing:border-box;
}
ul#accodion{max-width: 500px;margin: 0 auto;}
ul#accodion>li>a{
display: block;
padding: 15px;
color: #333;
background-color: #446CB3;
border: 1px solid #fff;;
font-family:arial;
color: #fff;
border-radius: 5px;
}
ul#accodion a.active,
ul#accodion a.hover{
background-color: #3560A0:
}
ul#accodion p{
background: #f5f5f5;
font-style: italic;
padding: 10px;
margin: 10px auto;
display: none;
}
WAY 2:- how it's work click here..
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Accordion - Default functionality</title>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script>
$( function() {
$( "#accordion" ).accordion();
} );
</script>
</head>
<body>
<div id="accordion">
<h3>Section 1</h3>
<div>
<p>
Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
</p>
</div>
<h3>Section 2</h3>
<div>
<p>
Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
suscipit faucibus urna.
</p>
</div>
<h3>Section 3</h3>
<div>
<p>
Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis.
Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero
ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis
lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.
</p>
<ul>
<li>List item one</li>
<li>List item two</li>
<li>List item three</li>
</ul>
</div>
<h3>Section 4</h3>
<div>
<p>
Cras dictum. Pellentesque habitant morbi tristique senectus et netus
et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in
faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia
mauris vel est.
</p>
<p>
Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
inceptos himenaeos.
</p>
</div>
</div>
</body>
</html>
No comments:
Post a Comment
If you have any problem please let me know.