Skip to content

Instantly share code, notes, and snippets.

@akshayvinchurkar1
Last active November 22, 2017 05:48
Show Gist options
  • Save akshayvinchurkar1/b1b1a53aba9126702463ec3cf79fbad8 to your computer and use it in GitHub Desktop.
Save akshayvinchurkar1/b1b1a53aba9126702463ec3cf79fbad8 to your computer and use it in GitHub Desktop.
dynamic id for collapse panels
// dynamic id and href generation
function buildidtree() {
var count = 0;
var elements = document.querySelectorAll(".add-sub-agenda");
var createnewagenda = document.querySelectorAll(".createnewagenda");
var id = [];
var href = [];
for(i = 0; i < elements.length; i++) {
var idvalue = id.push(elements[i].getAttribute('id') + count++);
elements[i].id = idvalue;
}
for(j = 0; j < elements.length; j++) {
var hrefvalue = href.push(createnewagenda[j].getAttribute("href") + count++);
createnewagenda[j].href = "#" + hrefvalue;
}
}
buildidtree();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment