I have a situation where I click on button to show and hide Div.
But what I want to achieve is that I want to have only icon to click. I don’t want to have a button. I want to click on the icon to show and hide div.
Then when one Div is click, others will hide. Example, if one div is open and I click on another div to open, and then the first div that was open should be closed. Also if i decide to click on icon for another div to open, then the second div will be closed too, while the third div will be open. If I go back and click the second div to pen, then the third div will be closed.
Although I am presenting only one div here, but it is how my other divs look.
HTML
<div class="FAQs">
<i class="fas fa-check-square" aria-hidden="true"></i>
<label>
General Question
</label>
<br />
<label>How to show Div</label>
<button onclick="javascript:return ShowDivonClick();"><i class="fa solid fa-sort-down" aria-hidden="true"></i></button>
<div id="divcontrol">
Show and Hide Div on Button Click in Asp.Net
</div>
</div>
Javascript
<script type="text/javascript">
function ShowDivonClick() {
$('#divcontrol').toggle("slow");
return false;
}
</script>