Skip to content

Instantly share code, notes, and snippets.

@rayinla
Last active January 18, 2018 16:26
Show Gist options
  • Save rayinla/6ab097457b115b97fb7bbde42c28bb2f to your computer and use it in GitHub Desktop.
Save rayinla/6ab097457b115b97fb7bbde42c28bb2f to your computer and use it in GitHub Desktop.
$(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
bluezy();
function bluezy(){
//We're saying, "I want to do fun things with <<that>> button object,
//not <<this>> window object you keep giving me
$(this).css("background-color", "blue");
}.bind(this)
});
});
@tereshchenkov
Copy link

Are u shure there're no mistakes?
'That' does not defiend and 'this' > .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment