Last active
February 24, 2016 21:23
-
-
Save stefbowerman/302a01b66522ff5885f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Option 1 | |
| $(body).on('click', function(){ | |
| console.log(this); // body | |
| }); | |
| // Option 2 | |
| function onClick(){ | |
| console.log(this); | |
| } | |
| $(body).on('click', onClick.bind($(body)); | |
| // Option 3/3.5 | |
| function onClick2(element){ | |
| console.log(element); | |
| } | |
| // These do the same thing | |
| $(body).on('click', onClick2.bind(this, $(body))); | |
| $(body).on('click', function(){ | |
| onClick2($(this)); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment