parser.js 786 B

12345678910111213141516171819202122232425262728
  1. var toggler = document.getElementsByClassName("caret");
  2. var i;
  3. for (i = 0; i < toggler.length; i++) {
  4. toggler[i].addEventListener("click", function() {
  5. this.parentElement.querySelector(".nested").classList.toggle("active");
  6. this.classList.toggle("caret-down");
  7. });
  8. }
  9. const elems = document.querySelectorAll("#myUL li span");
  10. var k=0;
  11. for (k; k<elems.length; k++) {
  12. elems[k].addEventListener('click', function() {
  13. console.log(this);
  14. document.querySelectorAll("#myUL li span").forEach(a=>a.style.color = "black");
  15. this.style.color = 'red';
  16. });
  17. }
  18. function showResult(showClass) {
  19. var cc = "." + showClass;
  20. document.querySelectorAll(".res").forEach(a=>a.style.display = "none");
  21. document.querySelectorAll(cc).forEach(a=>a.style.display = "block");
  22. }