document.getElementById() VS. getElementById()

前端 未结 6 1433
情书的邮戳
情书的邮戳 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条回答
  •  萌比男神i
    2020-12-07 04:00

    The correct way is indeed document.getElementById().

    The reason (speculation) it might work by itself is that depending on where you use it the current context may in fact be the document object, thus inexplicitly resulting in document.getElementById().

提交回复
热议问题