简体   繁体   中英

Javascript closures (I think)

I've got a piece of code I'm working with that was handed down to me by a previous developer. I am just trying to understand it better and not just use it naively. Here's the code:

slides.paginator.click(function (e) {
    e.preventDefault();
    interval.stop();
    switchSlide($(this).index());
    interval.start();
});

The part that I do not understand is the argument e that is being passed through this anonymous function. I have seen this before and I thought it had something to do with closures, but again, I am not sure. Can anyone give me a little insight into exactly how this parameter e works? I have seen it in other cases as well, such as with jQuery's AJAX methods.

Even pointing me in the right direction towards an article would be a great help. Thanks!

"e" comes from "event", check the jquery .click() docs http://api.jquery.com/click/

function(e){} replaces "handler(eventObject)"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM