过时
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

注意: You may simply replace it with /\s+/.test(Text.data) , /\s+/.test(Text.nodeValue) ,或 /\s+/.test(Text.textContent) . Putting any property that represents the textual content of the 文本 node into test() should do the same work just like the three example above.

Text.isElementContentWhitespace 只读特性返回 布尔 flag indicating whether or not the text node's content consists solely of whitespace.

句法

b = textnode.isElementContentWhitespace;
					

范例

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 */
					

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
isElementContentWhitespace 弃用 Chrome No Edge No Firefox ? — 10 IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android ? — 10 Opera Android No Safari iOS No Samsung Internet Android No

图例

不支持

不支持

弃用。不要用于新网站。

弃用。不要用于新网站。

另请参阅

元数据

  • 最后修改: