Text.isElementContentWhitespace

  • Revision slug: Web/API/Text.isElementContentWhitespace
  • Revision title: Text.isElementContentWhitespace
  • Revision id: 454035
  • 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 from the spec.
{{SpecName('DOM3 Core', 'core.html#Text3-isElementContentWhitespace', 'Text.isElementContentWhitespace')}} {{Spec2('DOM3 Core')}} Initial definition.

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatNo}} {{CompatVersionUnknown}}
Removed in {{CompatGeckoDesktop("10")}}
{{CompatNo}} {{CompatNo}} {{CompatNo}}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatNo}} {{CompatVersionUnknown}}
Removed in {{CompatGeckoMobile("10")}}
{{CompatNo}} {{CompatNo}} {{CompatNo}}

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 from the spec.</td>
    </tr>
    <tr>
      <td>{{SpecName('DOM3 Core', 'core.html#Text3-isElementContentWhitespace', 'Text.isElementContentWhitespace')}}</td>
      <td>{{Spec2('DOM3 Core')}}</td>
      <td>Initial definition.</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{CompatibilityTable}}</p>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatVersionUnknown}}<br />
          Removed in {{CompatGeckoDesktop("10")}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
      </tr>
    </tbody>
  </table>
</div>
<table class="compat-table">
  <tbody>
    <tr>
      <th>Feature</th>
      <th>Android</th>
      <th>Firefox Mobile (Gecko)</th>
      <th>IE Mobile</th>
      <th>Opera Mobile</th>
      <th>Safari Mobile</th>
    </tr>
    <tr>
      <td>Basic support</td>
      <td>{{CompatNo}}</td>
      <td>{{CompatVersionUnknown}}<br />
        Removed in {{CompatGeckoMobile("10")}}</td>
      <td>{{CompatNo}}</td>
      <td>{{CompatNo}}</td>
      <td>{{CompatNo}}</td>
    </tr>
  </tbody>
</table>
<h2 id="See_also">See also</h2>
<ul>
  <li>The {{domxref("Text")}} interface it belongs to.</li>
</ul>
Revert to this revision