Is there a way to have a callback on a jQuery object that doesn’t do anything else. something like:
$("div", this).do(function(){
$(this).hide();
});
The only way I know how to do that is:
var obj = $("div", this);
$(obj).hide();
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 use the
each()[docs] methodThis is useful if you need to run some custom code on each element in the jQuery object.
If all you need is to call another jQuery method like
.hide(), then you don’t need.each(). Most jQuery methods will operate on all elements in the set automatically. They call this “implicit iteration”.