using this.p()
inside jquery each() scope gives error. However it works perfectly out of each scope. So my problem is to avoid error inside each() scope.
class A() {
x() {
$("div.widget").each(function() {
this.p(); //give error
});
this.p(); // print this (working)
}
p() {
console.log("print this");
}
}