use*_*003 2 html javascript dom
我有一个元素(在 html 中)
<image xlink:url="https://abc" id="my_ele">
Run Code Online (Sandbox Code Playgroud)
我愿意
ele = document.getElementById("my_ele")
// Now want to get https://abc
Run Code Online (Sandbox Code Playgroud)
这个答案在这里Getting 'xlink:href' attribute of the SVG <image> element dynamic using JS in HTML DOM
说:
getAttributeNS('http://www.w3.org/1999/xlink', 'href');
Run Code Online (Sandbox Code Playgroud)
但我不确定在我的例子中这意味着什么。
(顺便说一句,谷歌文档显示这样的图像,至少在 Chrome 中。不知道他们为什么不使用正确的 IMG 标签。)
<image xlink:href="https://abc" id="my_ele">
Run Code Online (Sandbox Code Playgroud)
和
ele = document.getElementById("my_ele")
var url = ele.getAttributeNS('http://www.w3.org/1999/xlink', 'href');
Run Code Online (Sandbox Code Playgroud)