2019-02-12 12:18:48 +00:00
|
|
|
window.onload = function(e) {
|
|
|
|
var details = document.querySelectorAll("section.service-details");
|
|
|
|
for (var detail of details) {
|
|
|
|
var toggle = document.createElement("a");
|
2019-02-12 13:12:19 +00:00
|
|
|
var service_name = detail.previousElementSibling.querySelector("a").text;
|
|
|
|
toggle.text = "Læs mere om " + service_name;
|
2019-02-12 12:18:48 +00:00
|
|
|
toggle.onclick = function(e) {
|
|
|
|
e.preventDefault();
|
2019-02-12 13:12:19 +00:00
|
|
|
var service_name = e.target.previousElementSibling.previousElementSibling.querySelector("a").text;
|
|
|
|
var hide = e.target.previousElementSibling.classList.toggle("hidden");
|
|
|
|
e.target.text = (hide ? "Læs mere om " : "Skjul detaljer om ") + service_name;
|
2019-02-12 12:18:48 +00:00
|
|
|
}
|
|
|
|
detail.insertAdjacentElement('afterend', toggle);
|
|
|
|
detail.classList.add("hidden");
|
|
|
|
}
|
|
|
|
}
|