Skip to content

Commit e67ce6b

Browse files
Kentamanosscottgonzalez
authored andcommitted
Small update to Introducing Events
Adding a link to "DRY" in case people are not familiar with that acronym.
1 parent 286ed8b commit e67ce6b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

page/events/introduction-to-events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function sayHello( event ) {
126126
$( "#helloBtn" ).on( "click", sayHello );
127127
```
128128

129-
In this slightly different example, we're defining a function called `sayHello` and then passing that function into the `on` method instead of an anonymous function. So many online examples show anonymous functions used as event handlers, but it's important to realize that you can also pass defined functions as event handlers as well. This is important if different elements or different events should perform the same functionality. This helps to keep your code DRY.
129+
In this slightly different example, we're defining a function called `sayHello` and then passing that function into the `on` method instead of an anonymous function. So many online examples show anonymous functions used as event handlers, but it's important to realize that you can also pass defined functions as event handlers as well. This is important if different elements or different events should perform the same functionality. This helps to keep your code [DRY](http://en.wikipedia.org/wiki/Don%27t_repeat_yourself).
130130

131131
But what about that `event` argument in the `sayHello` function — what is it and why does it matter? In all DOM event callbacks, jQuery passes an *event object* argument which contains information about the event, such as precisely when and where it occurred, what type of event it was, which element the event occurred on, and a plethora of other information. Of course you don't have to call it `event`; you could call it `e` or whatever you want to, but `event` is a pretty common convention.
132132

0 commit comments

Comments
 (0)