# fromMutationObserver

[#](/rxjs-book/summary/rxjs_bindings/dom/mutation_observers/from_mutation_observer.md#rxdomfrommutationobservertarget-options)[Ⓢ](https://github.com/Reactive-Extensions/RxJS-DOM/blob/master/rx.dom.js#L471-L485) \[Ⓣ]\[1]

Creates an observable sequence from a `MutationObserver`. The `MutationObserver` provides developers a way to react to changes in a DOM. This requires `MutationObserver` to be supported in your browser/JavaScript runtime.

## Arguments

1. `target` *(Node)*: The Node on which to obserave DOM mutations.
2. `options` *(MutationObserverInit)*: A [`MutationObserverInit`](http://msdn.microsoft.com/en-us/library/windows/apps/dn252345.aspx) object, specifies which DOM mutations should be reported.

## Returns

*(Observable)*: An observable sequence which contains mutations on the given DOM target.

## Example

```javascript
var foo = document.getElementById('foo');

var obs = Rx.DOM.fromMutationObserver(foo, { 
    attributes: true, 
    childList: true, 
    characterData: true,
    attributeFilter: ["id", "dir"]
});

foo.dir = 'rtl';

// Listen for mutations
obs.subscribe(function (mutations) {
    mutations.forEach(function(mutation) {
        console.log("Type of mutation: " + mutation.type);

        if ("attributes" === mutation.type) {
            console.log("Old attribute value: " + mutationRecord.oldValue);
        }
    });
});
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://soufatn.gitbook.io/rxjs-book/summary/rxjs_bindings/dom/mutation_observers/from_mutation_observer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
