5 ms·
If you specify the same name on each `details` element they behave like an accordion automatically [1], no need for JavaScript. If you set one of them to open t
by rhdunn 10mo ago
If you specify the same name on each `details` element they behave like an accordion automatically [1], no need for JavaScript. If you set one of them to open that one will be initially open.
[1] https://developer.mozilla.org/en-US/blog/html-details-exclusive-accordions/#using_details_name_to_create_exclusive_accordions https://developer.mozilla.org/en-US/blog/html-details-exclus...
- crooked-v 10mo agoIt's not about using it as an accordion, it's about controlling the open/closed state from other interactions.
- 6510 10mo agodifferent things with the same name? O_O
- wartijn_ 10mo agoIt’s the name of the accordion and matches how radio buttons work. If you want to distinguish them, you’ll give them different ids.
- 6510 10mo agoI understand it, just wondering if it is good taste. On a different note, trying to use an accordion this simplistic is quite terrible. https://jsfiddle.net/8m0t5af6/ https://jsfiddle.net/8m0t5af6/ Or this? https://jsfiddle.net/8m0t5af6/1/ https://jsfiddle.net/8m0t5af6/1/ Not very nice.