过时
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 */
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 |
不支持
弃用。不要用于新网站。
文本
interface it belongs to.
文本
assignedSlot
isElementContentWhitespace
wholeText
AbortController
AbortSignal
AbstractRange
Attr
ByteString
CDATASection
CSSPrimitiveValue
CSSValue
CSSValueList
CharacterData
ChildNode
注释
CustomEvent
DOMConfiguration
DOMError
DOMErrorHandler
DOMException
DOMImplementation
DOMImplementationList
DOMImplementationRegistry
DOMImplementationSource
DOMLocator
DOMObject
DOMParser
DOMPoint
DOMPointInit
DOMPointReadOnly
DOMRect
DOMString
DOMTimeStamp
DOMTokenList
DOMUserData
Document
DocumentFragment
DocumentType
元素
ElementTraversal
Entity
EntityReference
事件
EventTarget
HTMLCollection
MutationObserver
节点
NodeFilter
NodeIterator
NodeList
NonDocumentTypeChildNode
ProcessingInstruction
PromiseResolver
范围
StaticRange
TextDecoder
TextEncoder
TimeRanges
TreeWalker
TypeInfo
USVString
UserDataHandler
XMLDocument