How to access Event.target in IE9?

前端 未结 6 642
耶瑟儿~
耶瑟儿~ 2021-02-08 02:12

The HTML DOM object model defines an Event object with a target property.

Looking at MSDN, Microsoft documents a target property. They also document srcElem

6条回答
  •  醉梦人生
    2021-02-08 02:40

    If you want to use event.target in IE9, you'll need to use addEventListener()-method to assign eventhandler to the element.

    document.getElementById('day').addEventListener('click',divClick,false); function divClick(e){ alert(e.target); divCell=this; : }

    In divClick() you can refer day simply using keyword this. Argument e contains a reference to the event-object itself.

    BTW, in MSDN you can find maybe more suitable IE-documentation for Web development instead of Windows development.

提交回复
热议问题