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.
The solution has two parts.
- Wrap every tree node title into
<span>. Then we can CSS-style them on
:hoverand handle clicks exactly on text, because
<span>width is exactly the text width (unlike without it).
- Set a handler to the
treeroot node and handle clicks on that