From what I understand the HTML5 spec lets you use IDs that are numbers like this.
<div id="1"></div>
<div id="2"></div>
I can access these fine using getElementById
but not with querySelector
. If I try do the following I get SyntaxError: DOM Exception 12 in the console.
document.querySelector("#1")
I'm just curious why using numbers as IDs does not work querySelector
when the HTML5 spec says these are valid. I tried multiple browsers.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…