Home › Forums › JavaScript › $(this) from within a seperately called function › Re: $(this) from within a seperately called function
It’s a matter of scope. When you run a function, it can only use the data it’s given. If inside “Function A” you want to call “Function B”, then “Function B” doesn’t automatically get to use all the data (variables, functions, arrays, etc.) that exist in “Function A” unless you specially pass “Function B” the data.
This is a must in order to prevent conflictions. What if “Function A” and “Function B” use a variable with the same name? Then simply calling “Function B” would screw “Function A” up.
In your case, you are handing the **specific element data** that “this” refers to to the removeBtn function. So now removeBtn knows what your talking about.
If that makes any sense.