6

when i have something like this

".mylabel click": function (el,ev){
//mycode in here 
}

what does el mean? what does ev mean?

I have tried searching it in canjs, but there isn't enough information.

mess
  • 63
  • 1
  • 1
  • 3

1 Answers1

7

Typically, el would be the element that received the click event. ev is the actual click event itself which would tell you if the user clicked with the right mouse button or left mouse button...etc.

Ralph Caraveo
  • 10,025
  • 7
  • 40
  • 52
  • can i have function (ev, el)? would that change the meaning? – mess Jul 26 '13 at 21:09
  • If you change the name of the parameters, your event would come in as the el argument and your element would come in as the ev argument in which case it would make the code confusing. But yes, you can do that. – Ralph Caraveo Jul 26 '13 at 21:10
  • is there a specific reason some people switch it around? – mess Jul 26 '13 at 21:13
  • People switch it around for different reasons but what is most important is consistency within a given framework. For example with jQuery their documentation will specify what the arguments represent and it is very wise to use their argument names to avoid confusion. Sometimes arguments are optional in which case it will be noted in the documentation by being surrounded in brackets. – Ralph Caraveo Jul 26 '13 at 21:22
  • and for the dollar sign $(element.target) what does that mean? – mess Jul 26 '13 at 21:24
  • The $() syntax is jquery's shortcut for selecting items within the dom. You can select via class names, tags, ids, and many other ways. There is too much to explain here, review the documentation to understand the breadth of this powerful construct. – Ralph Caraveo Jul 26 '13 at 21:29