[jQuery] Scope variables in anonymous functions?
What I'm trying to figure out is how I can access parent scopes from a
nested anonymous function. As you can see here, I'm managing to do
this by assigning "this" to variables, but I know that there's a way
to pass "this" into the anonymous functions:
$(".responsibleCouncil .category").each(function() {
var category = $(this);
var input = $(this).find(".toggler input");
var siblings = $(this).siblings();
input.click(function() {
$(siblings).find("ul").hide();
$(category).find("ul").show();
});
});
Basically, those three assignments at the top of the first anonymous
function would be unnecessary if I knew of a better way to access
"this" from nested functions.