setStringValue()
方法在
CSSPrimitiveValue
interface is used to set a string value. If the property attached to this value can't accept the specified unit or the string value, the value will be unchanged and a
DOMException
会被引发。
cssPrimitiveValue.setStringValue(stringType, stringValue);
unsigned short
representing the type of the value. Possible values are:
| 常量 | 描述 |
CSS_ATTR
|
The value is an
attr()
函数。
|
CSS_IDENT
|
The value is an identifier. |
CSS_STRING
|
The value is a
<string>
.
|
CSS_URI
|
The value is a
<uri>
.
|
DOMString
representing the new string value.
Void.
| 类型 | 描述 |
|---|---|
DOMException
|
An
INVALID_ACCESS_ERR
is raised if the CSS value doesn't contain a string value or if the string value can't be converted into the specified unit.
An NO_MODIFICATION_ALLOWED_ERR is raised if this property is read-only. |
| 规范 | 状态 | 注释 |
|---|---|---|
|
Document Object Model (DOM) Level 2 Style Specification
The definition of 'CSSPrimitiveValue.setStringValue' in that specification. |
过时 | 初始定义 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
setStringValue
弃用
|
Chrome 不支持 No | Edge 不支持 No | Firefox 不支持 ? — 62 | IE ? | Opera 不支持 No | Safari ? | WebView Android 不支持 No | Chrome Android 不支持 No | Firefox Android 不支持 4 — 62 | Opera Android ? | Safari iOS ? | Samsung Internet Android 不支持 No |
不支持
兼容性未知
弃用。不要用于新网站。
CSSPrimitiveValue
AbortController
AbortSignal
AbstractRange
Attr
ByteString
CDATASection
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