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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The answer is that
varkeyword 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 writevar selfyou’re declaring a local variable.