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

浏览器兼容性

{{ CompatibilityTable }}

Feature Chrome Edge Firefox (Gecko) Microsoft Edge Internet Explorer Opera Safari (WebKit)
Basic support {{CompatVersionUnknown}}[1] {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatIE("9.0")}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
dataset attribute {{CompatChrome("54")}} {{CompatUnknown}} {{CompatGeckoDesktop("51")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatOpera("41")}} {{CompatSafari("10.0")}}
Feature Android Android Webview Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support {{CompatNo}} {{CompatVersionUnknown}}[1] {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} [1]
dataset attribute {{CompatNo}} 54 {{CompatUnknown}} {{CompatGeckoMobile(51)}} {{CompatUnknown}} 41 10.0 54

[1] 属性 offsetParent, offsetTop, offsetLeft, offsetWidth, 和 offsetHeight 从Chrome 48开始被废弃.

相关链接