Quiz
- I'm still confused on when to use append vs appendTo. Can you explain this further?
Sure. It's the difference between "Rafa defeated Novak" and "Rafa lost to Novak". Which one was the winner?
Here's the issue is which one is the parent. Suppose we have
Both result in the same structure, with Ginny being a child of Molly, but the latter requires an extra line of code.
- could you say more about closest()
closest
goes up the ancestor chain stopping at the first (nearest) ancestor that matches the argument. So, if we start at Ginny in the previous example, and we look up the chain, we should find Molly: - could you say more about the difference between 'li' and
'descendant selector' as the second argument in an .on() method?
When we delegate event handling to an ancestor, we can say what kind of descendant is doing the delegating. Here's an extreme example:
The second argument is the kind of descendant. The language is the language of CSS selectors, so I usually describe it as a descendant selector.
The "li" in the reading is an example of a descendant selector.
- It was clear, but going over some examples with demos will be helpful
Great! We'll do that.