I want to use `<details><summary>` to create an accordion. And I want to open a certain accordion from a url in a mail or other page. I have found this code that maybe could work.
https://jsfiddle.net/6jvud52y/
jsFiddle reports some problems with this code. “details used out of scope”
How can I do this code simpler or better? Can I use a url like this: https://example.com/faq#2 to open the second accordion on a page?
@sibertauthorOct 06.2021 — #> @sibert#1637895 How can I do this code simpler or better?
By accident I found that details do not need a "class=open", but you need to change the "attribute" when open or closing the "details/summary". This makes the code a bit cleaner:
``<i> </i>function openTarget() { var id = location.hash.substring(1); document.getElementById(id).open = true; } openTarget();<i> </i>`</CODE> Besides this, you do not need to add a listener if you call from another window: