Defining JavaScript Event Object

后端 未结 4 1971
鱼传尺愫
鱼传尺愫 2021-01-15 12:24

Why am I getting an error for this piece of code?:

function catchevent() 
{
    eventSrcID=(event.srcElement)?event.srcElement.id:\'undefined\';

    eventty         


        
4条回答
  •  失恋的感觉
    2021-01-15 12:36

    you forgot to pass event in parameters.

    function catchevent(event) 
    {
        eventSrcID=(event.srcElement)?event.srcElement.id:'undefined';
    
        eventtype=event.type;
    
        status=eventSrcID+' has received a '+eventtype+' event.';
    }
    

提交回复
热议问题