How to make accordion via javascript? | Sololearn: Learn to code for FREE!

+1

How to make accordion via javascript?

How to make an accordion for element something like <div class="mytitle> My accordion title </div> <span class="mycontent> my content visible only on clicking title (drop down) </span>

10/13/2019 3:48:54 PM

Uzair Malim

1 Answer

New Answer

+1

You can try <summary> with <details>. https://www.w3schools.com/tags/tag_summary.asp (Edit) If you want to use JavaScript instead, you can handle the click event for the div, wherein you manipulate the `display` style of the span. But with summary-details it's easier.