Why does this variable only work inside a function?
Solution 1:
Inside of the function, this is in a different scope (Local). If you want to use the same scope, you should assign the first scope to a new variable called that or something else.
function someFunc() {
var that = this;
something.on("click", function() {
console.log(that);
});
};