function(e){e.something ...}什么是e? [英] function(e){e.something...} What is e?

查看:103
本文介绍了function(e){e.something ...}什么是e?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我写

$("#new_lang").click(function(e) 
{
  alert("something");
  e.stopPropagation();
});

这里的 e 是什么,为什么没有这个功能没有它?
为什么我可以写任何东西而不是e?

What is e here, and why doesn't the function work without it? Why can I write anything instead of e?

推荐答案

e 是处理程序收到的事件对象。你不需要特别使用e作为变量名,你可以随意调用它(只要它不是任意数量的关键字!),许多人称之为事件例如。

e is the event object that the handler receives. You need not use "e" specifically as the variable name, you can call it anything you want (as long as it's not any number of keywords!), many call it event for example.

,你可以没有它,因为它是第一个参数, arguments [0] 也有效,但我不会那样做。 你可以在这里看到这个,但我再次使用声明的声明就像它当前所以它非常明确的。

Yes, you can do without it, since it's the first argument, arguments[0] also works, but I wouldn't go that route. You can see this working here, but again I would just use the argument declared like it is currently so it's very explicit.

这篇关于function(e){e.something ...}什么是e?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆