function hide_element(element) { var classes = element.parentElement.className; element.parentElement.className = classes.replace('visible', ''); } function interact(e) { e.preventDefault(); ajaxPost(e.target); var identifier = e.target.getAttribute('data-id'); var elements = document.getElementsByClassName(identifier); for (var i = 0; i < elements.length; i++) { if (elements[i].className.includes('hidden')) { elements[i].className = elements[i].className.replace('hidden', ''); } else { elements[i].className += ' hidden'; } } return true; } function comment(e) { e.preventDefault(); ajaxPost(e.target); // TODO: display comment return true; } function ajaxPost(form) { fetch(form.action, { method : "POST", body: new FormData(form) }); }