Raphael.js:如何取消Element的attr?

时间:2012-06-15 06:41:42

标签: raphael

我有一个设置为元素的链接:

element.attr({href: 'http://google.com'});

现在我要删除一个链接。我在尝试:

element.attr({href: false});
element.attr({href: null});
element.attr({href: ''});

但它们都不起作用。

即使

delete element.attrs.href;

无济于事。

如何取消设置元素的属性?

1 个答案:

答案 0 :(得分:1)

你应该知道(使用RaphaëlAPI).attr()不会影响底层DOM元素,只是将属性附加到Raphaël对象。

如果您希望解决实际节点的href属性,您应该使用:

element.node.href = 'http://google.com';

或:

element.node.setAttribute('href', 'http://google.com');

查看'Element.node' on the Raphaël's documentation