Is it not possible to re-declare $.(this) after a $.click() function? because none of these seems to work:
$(this) = $(this).find('span');
var $(this) = $(this).find('span');
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.
You can only declare
var foowhenfoois a legal identifier.$(this)is the result of calling the function named$with argumentthisso it isn’t legal in a declaration.Nor should you overwrite
this– it will cause much head scratching in the future!If you want a local variable for storing the jQuery version of
thisthen a common convention is:where the (perfectly legal, but sometimes frowned upon)
$prefix allows you to remember that the variable is a jQuery object, and not a plain DOM element.That convention also allows you to spot the wasteful (but common) error of doing:
when
myobjis already a jQuery object.