Eric A. Meyer on Nostr: Today I learned about JS’s `Element.closest()`, which finds the closest ancestor of ...
Today I learned about JS’s `Element.closest()`, which finds the closest ancestor of an element based on a CSS selector you put into the parentheses. So `el.closest('section')` will find the nearest-ancestor `section` element to the element represented by `el`. *Very* nice.
https://developer.mozilla.org/en-US/docs/Web/API/Element/closestPublished at
2023-10-12 01:26:33Event JSON
{
"id": "6e1d5fa91120b10d098a10f5f49b211ccb644958df072471f8c05b26ae72ef87",
"pubkey": "6a32e47d258bb692f15a085dbdcb60ed381bb2921af6b4db1107a7ea545109cc",
"created_at": 1697073993,
"kind": 1,
"tags": [
[
"proxy",
"https://mastodon.social/users/Meyerweb/statuses/111219441257570897",
"activitypub"
]
],
"content": "Today I learned about JS’s `Element.closest()`, which finds the closest ancestor of an element based on a CSS selector you put into the parentheses. So `el.closest('section')` will find the nearest-ancestor `section` element to the element represented by `el`. *Very* nice. https://developer.mozilla.org/en-US/docs/Web/API/Element/closest",
"sig": "bcc4b4a182e79048f87b9e1c9e9313638e7e870cc462c6bb923b4e533c29c4bdc9ade323fb43726b9b8fb2b5ba53acb8316b6faeea162d54c03bf60ea0de7a3c"
}