javascript event.target not working in mozilla

后端 未结 5 667
春和景丽
春和景丽 2021-01-19 15:10


        
5条回答
  •  梦毁少年i
    2021-01-19 15:11

    Pass event to the function:

    click here 
    
    function fun(event, userID)
    {
        event= event|| window.event;
        var btn = event.target; 
        alert(btn.id);
    }
    

    OR

    Make sure your event is not undefined

    function fun(userID)
    {
        var e = event || window.event;
        var btn = e.target; 
        alert(btn.id);
    }
    

提交回复
热议问题