I want to attach a div with all the individual list items. When I click a list tag, the div which is attach to this particular div must have a CSS property display: block and if any div which is attach with other list item and have display: block, they must convert to display: none automatically.
$(document).ready(function(){
$('li').on("click",function(){
$('li').removeClass("active")
$(this).addClass('active')
})
})
#tours {
background-color:white;
box-shadow: 2px 3px 3px 0px;
border-top: 1px solid;
position: absolute;
width: 80%;
display: block;
}
#Visa {
background-color:white;
box-shadow: 2px 3px 3px 0px;
border-top: 1px solid;
position: absolute;
width: 80%;
display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul class="ul">
<li class="Tours active"> <a href="#tours"aria-expanded='true'> TOURS </a></li>
<li class="Visa"> <a href="#visa" aria-expanded="false">VISA</a></li>
<li class="hotels"> <a href="#hotels" aria-expanded="false">HOTELS</a> </li>
<li class="flights"> <a href="#flights"aria-expanded='false'>FLIGHTS</a> </li>
</ul>
<div class="content-area">
<div id="tours">
<p>Hi ,My name is safiqul islam uzzala,fdflkdfj Lorem ipsum dolor sit amet consectetur adipisicing elit. Sequi voluptas illo explicabo vero quis repellat cum odio sapiente. Ad, ipsa.</p>
<button class="btn btn-primary btn-lg">Try it</button>
</div>
<div id="visa">
<p>Lorem ipsum dolor sit ex illo unde. Earum modi, architecto sit amet libero aspernatur harum!</p>
<button class="btn btn-secondary btn-lg">try it</button>
</div>
with the help of jquery.