Is this line
$(this).attr("id").replace("_button","");
equivalent to this one?
this.attr("id").replace("_button","");
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.
since
thisalways contains a reference to theobject of invocation, it really depends where you call that code.If you call this within a
jQuery event handler,thisis a reference to theDOM elementitself, so you need to translate it into a jQuery object by calling$()before you can call jQuery methods on it. That in turn meanswill not work there.
If you’re writting a plugin method for instance,
thisalready IS ajQuery object(reference) and both lines would actually do the same. Of course, ifthisalready is ajQuery objectyou doing extra work, trying to parse it again.example: