How to list all element attributes in JS?

后端 未结 3 1085
孤城傲影
孤城傲影 2021-01-14 19:07

I would like to know all possible attributes of an element in JS.

I did :

s = document.getElementById(\"idSvg\");

r = s.attributes;

alert(r.length)         


        
3条回答
  •  -上瘾入骨i
    2021-01-14 19:48

    you can try this, but better off looking it up on w3.org

    (function() {
        var s = document.getElementById("idSvg");
    
        for (var key in s) {
            document.write(key + "
    "); } })();

提交回复
热议问题