minor
This commit is contained in:
parent
db182040c8
commit
eca29f5238
2 changed files with 4 additions and 4 deletions
|
@ -102,8 +102,8 @@ table.onclick = function(event) {
|
|||
Explanations:
|
||||
1. The method `elem.closest(selector)` returns the nearest ancestor that matches the selector. In our case we look for `<td>` on the way up from the source element.
|
||||
2. If `event.target` is not inside any `<td>`, then the call returns `null`, and we don't have to do anything.
|
||||
3. In case of nested tables, `event.target` may be a `<td>` outside of the current table. So we check if that's actually *our* `<td>`.
|
||||
4. And, if it is so, highlight it.
|
||||
3. In case of nested tables, `event.target` may be a `<td>` lying outside of the current table. So we check if that's actually *our table's* `<td>`.
|
||||
4. And, if it's so, then highlight it.
|
||||
|
||||
## Delegation example: actions in markup
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
|
||||
This text is always visible.
|
||||
|
||||
But if the page is shown inside a document from another domain, the div over it prevents any actions.
|
||||
But if the page was open inside a document from another domain, the div over it would prevent any actions.
|
||||
|
||||
<button onclick="alert(1)">Click doesn't work in that case</button>
|
||||
<button onclick="alert(1)">Click wouldn't work in that case</button>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue