Automatically open
element on ID call

前端 未结 2 656
孤街浪徒
孤街浪徒 2020-12-21 04:44

I\'m trying to automatically open a element when a containing is called by ID, for example: http://www.example.com/page.html#container. Ideally I\'d like this to scroll to

2条回答
  •  一整个雨季
    2020-12-21 05:32

    Below I provide solution that works for nested

    elements:

    With help of javascript you can:

    • track changes of hash anchor in url
    • react to them by changing open attribute of details elements accordingly

    Here is example that does it, code here → https://stackoverflow.com/a/55377750/544721

提交回复
热议问题