Javascript - Browser naming conventions for event attributes confusing me

前端 未结 2 448
情书的邮戳
情书的邮戳 2021-01-29 01:07

I\'ve been wondering why there is a difference in the attribute name for an event\'s target/sourceElement in JavaScript for different browsers.

event.srcElement         


        
2条回答
  •  悲&欢浪女
    2021-01-29 01:31

    Every time you load up a web page, the browser is turning the code it gets into a usable format which your computer understands. However the different browsers do it in slightly different ways, so sometimes exceptions need to be made for certain browsers.

    The browser is a translator, sometimes the translation can be different depending on who does the translation.

    In this specific case I would guess Internet explorer understand srcElement, while all the others understand target.

提交回复
热议问题