How to make accordion via javascript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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>

13th Oct 2019, 3:48 PM
Uzair Malim
Uzair Malim - avatar
1 Answer
+ 1
You can try <summary> with <details>. (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.
13th Oct 2019, 5:24 PM