【发布时间】:2017-03-04 12:23:51
【问题描述】:
有时您会看到我们需要在 javascript 中使用 event 对象。
这是一些代码,我们如何传递event。
function test(e){
console.log(e);
e.preventDefault();
console.log("you are not going to redirect");
}
HTML
<a href="www.google.com" onclick="test(event)">GOOGLE</a>
如果您想在函数中传递事件,只需在函数参数中传递event。
【问题讨论】:
-
我想用
e.preventDefault()你可以看更新问题 -
您的代码似乎正确,问题是您的代码没有显示与您的功能相符的代码
标签: javascript jquery