As a beginner in development, I am working on implementing an accordion in JavaScript. In my HTML file, I have separate divs for question titles and another div for the "+" sign. My objective is to change the "+" sign to "-" and reveal the answer when a user clicks on a div with the class "accordionTitle". Can someone provide guidance on the best approach to achieve this?
HTML:
<section class="qnaSection">
<h1 class="qnaTitle">FAQ</h1>
<div id="qnaContainer" class="qnaContainer"></div>
</section>
CSS:
.qnaSection {
background-color: rgb(35, 57, 94);
color: var(--brown);
}
.qnaTitle {
text-align: center;
margin: 10px 0;
font-size: 28px;
}
.qnaContainer {
width: 90%;
max-width: 1000px;
margin: 20px auto;
}
.accordionItem {
background-color: rgb(222, 222, 222);
color: black;
margin: 10px 0;
border-radius: 10px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.25);
}
/* Rest of the CSS remains unchanged */
toggleBar()