DocumentFragment.find method
DocumentFragment › find
Official
Finds the first descendant element that matches the selector.Signature:
find(selector: string): Element | nullParameters:
| Parameter | Type | Description |
|---|---|---|
| selector | string | The selector to find the element with. |
Returns: Element | null — The first descendant element that matches the selector, or null if no match is found.
Remarks:
See bughttps://forum.obsidian.md/t/bug-find-findall-findallself/98108. Example:
const fragment = createFragment();fragment.createEl('strong', { cls: 'foo' });console.log(fragment.find('.foo')); // <strong class="foo"></strong>console.log(fragment.find('.bar')); // null