How to list all element attributes in JS?

后端 未结 3 1084
孤城傲影
孤城傲影 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:51

    I don't think it is possible, as JS have no clue whatsoever about DTD format. You need to look at the tag specification (taking into account the proper doctype that tag will be used in).

提交回复
热议问题