data-* - SVG: Scalable Vector Graphics 编辑
The data-*
SVG attributes are called custom data attributes. They let SVG markup and its resulting DOM share information that standard attributes can't, usually for scripting purposes. Their custom data are available via the SVGElement
interface of the element the attributes belong to, with the SVGElement.dataset
property.
The *
can be replaced by any characters allowed in XML's rules for names, with the following restrictions:
- Can't start with
xml
. - No semicolons (
;
,U+003A
). - No capital
A
toZ
letters.
The SVGElement.dataset
property is a DOMStringMap
that provides the attribute data-test-value
via SVGElement.dataset.testValue
. Hyphen characters (-
, U+002D
) are removed and the next letter is capitalized, resulting in the camelCase format.
Specifications
Specification | Status | Comment |
---|---|---|
Scalable Vector Graphics (SVG) 2 The definition of 'data-*' in that specification. | Candidate Recommendation | Custom data attributes are new in SVG 2. |
Browser compatibility
BCD tables only load in the browser
See also
SVGElement
- The
SVGElement.dataset
property used to access these attributes from scripts. - Using data attributes
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论