Skip to content

Update index.md #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update index.md
I've added a jquery example of how to include options within the observer.
 
Feel free to ignore this, I just thought it might be a half decent suggestion to include.
  • Loading branch information
eliotcole authored Sep 23, 2024
commit 73c2cf299fa171195ab406606a6b4ed2afe138bb
19 changes: 19 additions & 0 deletions content/guide/observing-dom/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,24 @@ VM.observe(document.body, () => {
}
});
```
To add options to the same code one can use the following:

```js
VM.observe(document.body, () => {
// Find the target node
const $node = $('.profile');

if ($node.length) {
$node.prepend('<h1>Profile</h1>');

// disconnect observer
return true;
}
}, {
childList: true,
subtree: true,
// any other options here
});
```

[vm-dom]: https://github.com/violentmonkey/vm-dom
Loading