document.getElementById() VS. getElementById()

前端 未结 6 1431
情书的邮戳
情书的邮戳 2020-12-07 03:43

It is common for me to register javascript functions for certain events by doing something like:

myBtn.Attributes.Add(\"onClick\", \"Validate(getElementById(         


        
6条回答
  •  眼角桃花
    2020-12-07 03:59

    Any function or variable you access without an owning object (ex: document.getElementById) will access the property from window.

    So getElementById is actually window.getElementById, which isn't natively defined (unless you defined it before (ex: getElementById = document.getElementById).

提交回复
热议问题