For example :
function masterMethod(this, action){
// (action); <-- But action requires $(this) to be defined.
}
$(".item").click(function(){
function minorMethod(){
alert($(this));
}
masterMethod($(this), minorMethod)
});
How would I execute the action and pass $(this) in the masterMethod?
You can use
call[MDN]:Note the two changes I made: Instead of passing
$(this)tomasterMethod, I passedthis(the DOM element), since insideminorMethod, you are passingthisagain to jQuery. If you were passing$(this)you would end up passing a jQuery object to jQuery again, i.e.$($(this)), which is unnecessary.I’m not sure if it actually would throw an error, but in any case, you should not name your argument
this.