我想知道 JS 中元素的所有可能属性。
我做到了:
s = document.getElementById("idSvg");
r = s.attributes;
alert(r.length);
...
...
<svg width="450" height="250" id="idSvg">
...
</svg>
但结果是 3。似乎是我使用的属性数量(宽度、高度和 ID),但我想列出一个 SVG 元素可能具有的所有可能属性。
感谢您的帮助, 罗格
最佳答案
你可以试试这个,但最好在 w3.org 上查找它
(function() {
var s = document.getElementById("idSvg");
for (var key in s) {
document.write(key + "<br />");
}
})();
关于javascript - JS中如何列出所有元素属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5867477/