Reputation: 10969
OK, simple:
self = $(this);
Throws a JavaScript error in IE8 when it's inside an event handler. It works in every other browser.
var self = $(this);
Throws no error. Why?
Upvotes: 1
Views: 644
Reputation: 413727
The answer is that var
keyword staring back out at you.
When you reference just plain self
, you're referencing a global variable and IE won't let you change it. When you write var self
you're declaring a local variable.
Upvotes: 7