【发布时间】:2018-05-21 14:26:44
【问题描述】:
在函数内部我有一个 svg 对象,当我控制台日志时它看起来像这样:
<svg height="100" version="1.1" width="1000" xmlns="http://www.w3.org/2000/svg"
style="overflow: hidden; position: relative;">
<desc style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Created with Raphaël 2.1.0</desc>
<defs style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></defs>
<path fill="#000000" stroke="#000000" d="M0,0L12,12L12,-12L0,0" transform="matrix(1,0,0,1,0,50)"
opacity="0" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); opacity: 0;">
</path>
<rect x="0" y="10" width="30" height="80" r="0" rx="0" ry="0"
fill="#000000" stroke="#000" opacity="0" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); opacity: 0;"></rect>
<image x="134" y="10" width="30" height="80" preserveAspectRatio="none"
xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:href="/static/img/pads/numberline/symbols/leftParen.png"
style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">
</image>
</svg>
现在我需要更改 svg 元素内图像的 href。
到目前为止我所做的是设置宽度svgObject.setAttribute('width', 1000);
但是如何更改和选择图像元素的 href 属性?
【问题讨论】:
标签: javascript jquery svg