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

后端 未结 5 517
青春惊慌失措
青春惊慌失措 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 05:00

    Again from http://api.jquery.com/bind/ as linked on the previous question:

    The handler callback function can also take parameters. When the function is called, the JavaScript event object will be passed to the first parameter.

    The event object is often unnecessary and the parameter omitted, as sufficient context is usually available when the handler is bound to know exactly what needs to be done when the handler is triggered. However, at times it becomes necessary to gather more information about the user's environment at the time the event was initiated.

    There is a lot of useful info on that page. :)

提交回复
热议问题