I dont understand javascript syntax well,my question:
How jquery define click function for get parameter inside anonymous function?
The Case:
$("a").click(function(event) {
alert(event.type);
});
in C the function should be defined:
void click(fn,event){
}
in javascript its looks to me that she defined as- (but where defined event?):
click (fn){
}
please explain to me the jquery syntax of click function code source here.
Thanks, Yosef
eventis passed to the anonymous function? Btw. the C equivalent would be to pass a function pointer toclickwhich accepts a parameter, not both, function pointer and parameter. In JavaScript you can just write this inline. It is the same asfunction handler(event) {/*...*/} $("a").click(handler);. There is nothing special about it.clickis just a shorthand forbindwhich itself usesjQuery.event.addto attach the event handler. You have to look at this implementation. But the code is quite complex and optimized. In the end it is the same as what is shown in the answers you already have. And still, I think you have to phrase your question better.