can I have a div with id as number?

后端 未结 7 2266
失恋的感觉
失恋的感觉 2020-11-22 10:13

Can I have a div with id as number?

eg

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 10:25

    While TJ Crowder's answer is conceptually good, it doesn't work for descendant CSS selectors.

    Escaping only the first character followed by space does work however (as at Chrome 49)

    Assume the following HTML snippet:

    
     
    play that funky music

    The following statement:

    document.querySelector("#\\31 23456 .blah .yadah").style.fontStyle = "italic";
    

    correctly displays play that funky music

提交回复
热议问题