`. But, as we can see in line `(**)`, the value of the old `div` variable hasn't changed!
The `outerHTML` assignment does not modify the DOM element (the object referenced by, in this case, the variable 'div'), but removes it from the DOM and inserts the new HTML in its place.
So what happened in `div.outerHTML=...` is:
- `div` was removed from the document.
- Another piece of HTML `
A new element
` was inserted in its place.
- `div` still has its old value. The new HTML wasn't saved to any variable.
It's so easy to make an error here: modify `div.outerHTML` and then continue to work with `div` as if it had the new content in it. But it doesn't. Such thing is correct for `innerHTML`, but not for `outerHTML`.
We can write to `elem.outerHTML`, but should keep in mind that it doesn't change the element we're writing to ('elem'). It puts the new HTML in its place instead. We can get references to the new elements by querying the DOM.
## nodeValue/data: text node content
The `innerHTML` property is only valid for element nodes.
Other node types, such as text nodes, have their counterpart: `nodeValue` and `data` properties. These two are almost the same for practical use, there are only minor specification differences. So we'll use `data`, because it's shorter.
An example of reading the content of a text node and a comment:
```html run height="50"
Hello
```
For text nodes we can imagine a reason to read or modify them, but why comments?
Sometimes developers embed information or template instructions into HTML in them, like this:
```html
Welcome, Admin!
```
...Then JavaScript can read it from `data` property and process embedded instructions.
## textContent: pure text
The `textContent` provides access to the *text* inside the element: only text, minus all `
`.
For instance:
```html run
Headline!
Martians attack people!
```
As we can see, only text is returned, as if all `` were cut out, but the text in them remained.
In practice, reading such text is rarely needed.
**Writing to `textContent` is much more useful, because it allows to write text the "safe way".**
Let's say we have an arbitrary string, for instance entered by a user, and want to show it.
- With `innerHTML` we'll have it inserted "as HTML", with all HTML tags.
- With `textContent` we'll have it inserted "as text", all symbols are treated literally.
Compare the two:
```html run
```
1. The first `` gets the name "as HTML": all tags become tags, so we see the bold name.
2. The second `
` gets the name "as text", so we literally see `
Winnie-the-pooh!`.
In most cases, we expect the text from a user, and want to treat it as text. We don't want unexpected HTML in our site. An assignment to `textContent` does exactly that.
## The "hidden" property
The "hidden" attribute and the DOM property specifies whether the element is visible or not.
We can use it in HTML or assign using JavaScript, like this:
```html run height="80"
Both divs below are hidden
With the attribute "hidden"
JavaScript assigned the property "hidden"
```
Technically, `hidden` works the same as `style="display:none"`. But it's shorter to write.
Here's a blinking element:
```html run height=50
A blinking element
```
## More properties
DOM elements also have additional properties, in particular those that depend on the class:
- `value` -- the value for `
`, `