I have lines of code like this:
$(this).parent().parent().children().each(function(){
// do something
});
It works well. But I need to run these lines multiple times. So I have created a function and pass $(this) parameter to a function:
myFunc( $(this) );
function myFunc(thisObj) {
thisObj.parent().parent().children().each(function(){
// do something
});
}
But in this way, It didn't work.
jQuery will automatically invoke your function with the proper context set.
you can check this link.
http://jsfiddle.net/zEXrq/38/
If you work in no-conflict mode (i.e. out of global scope), one of the possibilities is: