---
title: SVGElement
slug: Web/API/SVGElement
translation_of: Web/API/SVGElement
---
{{APIRef("SVG")}}
所有SVG DOM类的父类.
{{InheritanceDiagram}}
属性
- {{domxref("SVGElement.dataset")}}{{readonlyInline}}
- A {{domxref("DOMStringMap")}} object which provides a list of key/value pairs of named data attributes which correspond to custom data attributes attached to the element. These can also be defined in SVG using attributes of the form {{SVGAttr("data-*")}}, where
*
is the key name for the pair. This works just like HTML's {{domxref("HTMLElement.dataset")}} property and HTML's {{htmlattrxref("data-*")}} global attribute.
- {{domxref("SVGElement.id")}}{{readonlyInline}}
- A {{domxref("DOMString")}} representing the value of the {{SVGAttr("id")}} attribute on the given element, or the empty string if
id
is not present.
- {{domxref("SVGElement.xmlbase")}}{{readonlyInline}}
- A {{domxref("DOMString")}} corresponding to the {{SVGAttr("xml:base")}} attribute on the given element.
- {{domxref("SVGElement.ownerSVGElement")}}{{readonlyInline}}
- An {{domxref("SVGSVGElement")}} referring to the nearest ancestor {{SVGElement("svg")}} element.
null
if the given element is the outermost <svg>
element.
- {{domxref("SVGElement.viewportElement")}}{{readonlyInline}}
- The {{domxref("SVGElement")}}, which established the current viewport. Often, the nearest ancestor {{SVGElement("svg")}} element.
null
if the given element is the outermost <svg>
element.
方法
SVGElement
类本身没有方法, 但拥有从父类{{domxref("Element")}}继承的方法.
规范
Specification |
Status |
Comment |
{{SpecName("SVG2", "types.html#InterfaceSVGElement", "SVGElement")}} |
{{Spec2("SVG2")}} |
Adds the {{domxref("SVGElement.dataset", "dataset")}} property. |
{{SpecName("SVG1.1", "types.html#InterfaceSVGElement", "SVGElement")}} |
{{Spec2("SVG1.1")}} |
Initial definition |
浏览器兼容性
{{Compat("api.SVGElement")}}
相关链接
- HTML {{htmlattrxref("data-*")}} 属性
- SVG {{SVGAttr("data-*")}} 属性
- 使用数据属性