addEventListener("load", addCollaps); function addCollaps() { var coll = document.getElementsByClassName("collapsible"); for (var c of coll) { c.addEventListener("click", function() { this.nextElementSibling.classList.toggle("collapsed"); }); } } // TODO : kann raus function loadJson(filename, callback) { var xhr = XMLHttpRequest(); xhr.onreadystatechange = function() { if(this.readyState == 4 && this.status == 200) { callback(JSON.parse(xhr.responseText)); } } xhr.open(get, filename); xhr.send(); }