Check out this code snippet:
<p class="faq" onclick="toggleVisibility('answer1');">
How can I restrict email sending on my website?
</p>
<div id="answer1" class="hide"><sometext></div>
these are my CSS styles!
.faq{
padding: 0px 16px 0px 0px;
background-repeat: no-repeat;
background-image: url(miniic_li.png);
background-position: right 5px;
}
.hide{
display:none;
}
.show{
font-family:Tahoma, Geneva, sans-serif;
margin-right:25px;
}
This code is functioning perfectly.
Once a user clicks the <p>
, the visibility of the <div>
changes to show the content. However, I also want the <div>
to hide when the same <p>
is clicked again. What should I modify in the code?