Chrome中能获取到event, FireFox获取不到event的情况

版权声明:你可以转载,但要标明出处 https://blog.csdn.net/qq_41605091/article/details/82465356

Firefox中获取event,需通过参数传递event
html:

onclick = add(event);

js:

function add(event){ // Firefox中需通过参数传递event
    console.log(event);
}

AngularJs:
html:

onclick = add($event); // 在Firefox中必须要带$

js:

function add(event){ // 通过参数传递event
    console.log(event);
}

Chrome中不用通过参数传递,可以直接使用
html:

onclick = add();

js:

function add(){
    console.log(event); // 可以直接获取
}

猜你喜欢

转载自blog.csdn.net/qq_41605091/article/details/82465356