Derse geri dön
Bu materyal sadece عربي, English, Español, Français, Indonesia, Italiano, 日本語, 한국어, Русский, Українська, 简体中文 dillerinde mevcuttur. Lütfen Türkçe diline çevirmek için bize yardım edin.

Tree menu

önem: 5

Create a tree that shows/hides node children on click:


  • Only one event handler (use delegation)
  • A click outside the node title (on an empty space) should not do anything.

Görevler için korunaklı alan aç.

The solution has two parts.

  1. Wrap every tree node title into <span>. Then we can CSS-style them on :hover and handle clicks exactly on text, because <span> width is exactly the text width (unlike without it).
  2. Set a handler to the tree root node and handle clicks on that <span> titles.

Çözümü korunaklı alanda aç.