JavaScript

DOM traversal (parent, children, closest)

Në shqip: Lëvizja nëpër DOM

ShpjegimiSQ

Nga një element mund të lëvizësh: parentElement (prindi), children (fëmijët), nextElementSibling (vëllai i radhës) dhe closest(".karta") (paraardhësi më i afërt që përputhet).

EnglishEN

From one element you can move around: parentElement (the parent), children (the kids), nextElementSibling (the next sibling) and closest(".card") (the nearest matching ancestor).

Si ta mendosh

Si të lëvizësh në pemën familjare: te prindi, fëmijët, vëllezërit.

Lexoje në anglisht

Like moving around a family tree: to the parent, the children, the siblings.

Shembull kodijavascript

butoni.addEventListener("click", (e) => {
  const karta = e.target.closest(".karta");
  karta.remove();
});

Terma të lidhur