How to access Event.target in IE9?

前端 未结 6 647
耶瑟儿~
耶瑟儿~ 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

    use:

    var target = (event.target !== undefined)? event.target.name : event.srcElement.tagName;
    

    then:

    if ( target === 'A' || target === '...') {
        ...
    }
    

    OR: simple use:

    var target = event.srcElement.tagName;
    

    tested on Chrome 35 :)

提交回复
热议问题