A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/dom/Node/normalize below:

normalize ยท WebPlatform Docs

normalize Summary

Merges adjacent DOM objects to produce a normalized document object model.

Method of dom/Nodedom/Node

Syntax
 node.normalize();
Return Value

No return value

Examples
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Node.normalize() example</title>
</head>

<body>


<script type="text/javascript">
var wrapper = document.createElement("div");

wrapper.appendChild( document.createTextNode("Part 1 ") );
wrapper.appendChild( document.createTextNode("Part 2 ") );




alert('wrapper.childNodes.length==='+wrapper.childNodes.length);
wrapper.normalize();
document.body.appendChild(wrapper);


alert('wrapper.normalize();wrapper.childNodes.length==='+wrapper.childNodes.length);

</script>

</body>
</html>
Usage
 By calling object.normalize before the subelements of an object are manipulated, you ensure that the document object model has a consistent structure.  The normal form is useful for operations that require a consistent document tree structure, and it ensures that the document object model view is identical when it is saved and reloaded.
Notes

The normalize method does not merge adjacent CDATA sections, allowing for an inconsistent object model when CDATA sections are present.

Related specifications
DOM Level 3 Core
Recommendation
Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4