Text.isElementContentWhitespace

  • Revision slug: Web/API/Text.isElementContentWhitespace
  • Revision title: Text.isElementContentWhitespace
  • Revision id: 454011
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{ DomRef("Text") }}

{{ deprecated_header("") }}

The Text.isElementContentWhitespace read-only property returns a {{domxref("Boolean")}} flag indicating whether or not the text node's content consists solely of whitespace.

Syntax

b = textnode.isElementContentWhitespace;

Example

In the example below, we create a node with mixed display and whitespace characters and the attribute is false.

var tn = document.createTextNode("Hello world");
tn.isElementContentWhitespace; /* evaluates to false */

For a node that is all whitespace characters, the isElementContentWhitespace evaluates to true.

var ws = document.createTextNode("  \t \r\n   ")
ws.isElementContentWhitespace; /* evaluates to true */

Specifications

Specification Status Comment
{{SpecName('DOM WHATWG', '#text', 'Text')}} {{Spec2('DOM WHATWG')}} Removed the replaceWholeText() method.
{{SpecName('DOM3 Core', 'core.html#Text3-isElementContentWhitespace', 'Text')}} {{Spec2('DOM3 Core')}} Initial definition.

Browser compatibility

See also

  • The {{domxref("Text")}} interface it belongs to.

Revision Source

<p>{{ DomRef("Text") }}</p>
<p>{{ deprecated_header("") }}</p>
<p>The <strong><code>Text.isElementContentWhitespace</code></strong> read-only property returns a {{domxref("Boolean")}} flag indicating whether or not the text node's content consists solely of whitespace.</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">
<em>b</em> = <em>textnode</em>.isElementContentWhitespace;</pre>
<h2 id="Example" name="Example">Example</h2>
<p>In the example below, we create a node with mixed display and whitespace characters and the attribute is <code>false</code>.</p>
<pre class="brush: js">
var tn = document.createTextNode("Hello world");
tn.isElementContentWhitespace; /* evaluates to false */
</pre>
<p>For a node that is all whitespace characters, the <code>isElementContentWhitespace</code> evaluates to true.</p>
<pre class="brush: js">
var ws = document.createTextNode("  \t \r\n   ")
ws.isElementContentWhitespace; /* evaluates to true */
</pre>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
  <tbody>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
    <tr>
      <td>{{SpecName('DOM WHATWG', '#text', 'Text')}}</td>
      <td>{{Spec2('DOM WHATWG')}}</td>
      <td>Removed the <code>replaceWholeText()</code> method.</td>
    </tr>
    <tr>
      <td>{{SpecName('DOM3 Core', 'core.html#Text3-isElementContentWhitespace', 'Text')}}</td>
      <td>{{Spec2('DOM3 Core')}}</td>
      <td>Initial definition.</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<h2 id="See_also">See also</h2>
<ul>
  <li>The {{domxref("Text")}} interface it belongs to.</li>
</ul>
Revert to this revision