Access event.target in IE8 unobtrusive Javascript

前端 未结 4 1387
忘掉有多难
忘掉有多难 2021-01-04 01:37

The following function gets the target element in a dropdown menu:

function getTarget(evt){

 var targetElement = null;

 //if it is a standard browser
 if (         


        
4条回答
  •  暖寄归人
    2021-01-04 02:33

    I met this problem too. And the problem is: in IE8, the event must be window.event, not the event that is declared in params.

    I fixed as below:

        function onclick(event){
          if (is_ie8()){
            clicked_element = window.event.srcElement
          } else {
            clicked_element = event.target
          }
        }
    

提交回复
热议问题