I have the following:
var Save = $('th:first')[0];
$('th').click(function() {
if (Save !== this) {
Save = this;
...
}
});
How do I put “Save” into a closure scope?
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.
With jQuery, I tend to wrap the whole lot in a function, that passes in the
jQueryobject as$, to avoid namespace clashes on that shorthand, as recommended by the jQuery documentation.Any variables within that scope, for instance your
var Save, are then out of the global name scope, in a closure.