Is there a JavaScript solution to generating a “table of contents” for a page?

后端 未结 12 1737
广开言路
广开言路 2020-12-12 17:21

I have headers in

through
tags. Is there a way that I can use JavaScript to generate a table of contents for the contents tha

12条回答
  •  难免孤独
    2020-12-12 18:02

    Are you looking for a prepackaged solution or are you asking how this can be implemented?

    For the latter, you could use getElementsByTagName() recursively on

    through
    XPath to iterate through all elements and construct the corresponding nested

提交回复
热议问题