Prototype This page is part of the Prototype JavaScript framework documentation.
Overview | (...)

Element.cleanWhitespace removes all empty text node children of an element. This is useful for situations where unwanted whitespace might interfere with DOM traversal.

Syntax


  Element.cleanWhitespace( element );

Example


  <ul id="list">
    <li>One</li>
    <li>Two</li>
  </ul>

  <script type="text/javascript">
    Element.cleanWhitespace('list');
  </script>

will convert the UL to look like:


<ul id="list"><li>One</li><li>Two</li></ul>

(Note that this is a a representation of the DOM in XHTML terms for easier understanding)

Notes

IE doesn’t create empty text nodes, except for &nbsp’s and linebreaks after LI nodes.