Created
November 28, 2017 04:13
-
-
Save kaecyra/e4763a2a7b7c5270c1f3725543f29531 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createTOC() { | |
var list = document.getElementByTagName("UL")[0]; | |
var headingText | |
var TOCEntry | |
for (i = 0; i <= 10; i++) { | |
headerText = document.getElementById(i).innerHTML; | |
TOCEntry = document.createElement("li") | |
TOCEntry.innerHTML = "<a href=#" + i + ">" + headingText + "</a>"; | |
list.appendChild(TOCEntry); | |
} | |
} | |
document.addEventListener("DOMContentLoaded", function(event) { | |
createTOC(); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment