/* get every click event on input tags and send it to foo */
$('input').click( function() {
foo($(this));
});
function foo(obj) {
/* do something with obj.. */
}
with above code, I will have an input object passed into function foo as an argument obj.
How should I use obj? do I need to re-run selector, like $(obj) to use all jquery-specific methods?
some more question : answers say that I have no need to wrap obj with $() again. what will happen if I re-wrap obj with $(obj)? (suppose function foo can take both jquery-selected objects and non-jquery-selected objects)
You are passing the jQuery object, so no need to wrap
$()again.Did you try running a jQuery function inside the
foofunction?You can simply do
obj[0]to get the originalthisobject.