Last active
December 9, 2017 15:48
-
-
Save rayinla/c3bdb2db2b2ccc82593473062ca71ede to your computer and use it in GitHub Desktop.
This file contains 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
$(document).ready(function(){ | |
//It is important to notice that 'button' is a DOM object with various methods | |
$('button').on('click', function(){ | |
//We must preserve the button's context | |
var that = this; | |
bluezy(); | |
function bluezy(){ | |
//We're saying, "I want to do fun things with <<that>> button object, | |
//not <<this>> window object you keep giving me | |
$(that).css("background-color", "blue"); | |
console.log(this); // >> Window | |
console.log(that);// >> <button> | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment