Start by fixing the code. You have a useless function declaration, you can use $.proxyas
$('a').on('click', $.proxy(this.close, this));
Now a second solution based self
- requires only basic javascript knowledge
- does not require jQuery
- we read a little, especially since you often reuse a variable
self - much faster
This is probably why it is used more.
Please note that if you do not need to be compatible with IE8, you can use bind :
$('a').on('click', this.close.bind(this));
source
share