function(e){e.something…} What is e?

后端 未结 5 478
青春惊慌失措
青春惊慌失措 2021-01-06 04:22

When I write

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

What is e here, and

5条回答
  •  孤城傲影
    2021-01-06 04:48

    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.

    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.

提交回复
热议问题