html element id as javascript variable

前端 未结 3 2010
后悔当初
后悔当初 2021-02-19 16:43

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.

提交回复
热议问题