【发布时间】:2016-01-08 02:12:48
【问题描述】:
我可以像这样使用 ECMAScript 操作 SVG 链接元素的 xlink:href 属性:
var xlinkns = "http://www.w3.org/1999/xlink";
myLink.setAttributeNS(xlinkns, "xlink:href", "#");//add href attribute to the link
myLink.removeAttributeNS(xlinkns, "href");//remove the href attribute from the link
我的问题是:用 javascript 或 snap SVG 做同样事情的正确语法是什么?
【问题讨论】:
-
JavaScript 是 ECMAScript 的一种实现。你做的完全一样。 API 也不是 ECMAScript 的一部分。这是DOM API,它与语言无关。
-
Felix,我知道 javascript 是 ECMAScript 的一种实现,因此我尝试过:myLink.setAttributeNS(xlinkns, "xlink:href", "google.com"); 它没有不行。
标签: javascript svg snap.svg