html element id as javascript variable

前端 未结 3 1679
感动是毒
感动是毒 2021-02-19 17:10

Consider the following code:





      
3条回答
  •  北海茫月
    2021-02-19 17:18

    Yes, it's been around for a very long time, which is likely the only reason it exists. Removing such a "feature" will break compatibility with existing web sites, which browser vendors are very reluctant to do.

    You're correct in saying that it's not a good idea. It's a profoundly bad idea and can lead to naming conflicts as well as unnecessary pollution of the global namespace.

提交回复
热议问题