Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript $(this) from within a seperately called function Re: $(this) from within a seperately called function

#121286
__
Participant

You might find [this](http://yehudakatz.com/2011/08/11/understanding-javascript-function-invocation-and-this/) interesting.

IIUC, `this` inside `removeBtn` would be “undefined” (or, in most browsers, would fall back to `[object Window]`).

To make your example work:

$(“.save”).click( function(){
removeBtn( this );
});

function removeBtn( context ){
$(context).remove();
}