Lets say this is our function:
$('ul li').bind('click', function(){
$('iframe').each(function(){
// who is this???
alert(this);
});
});
As you can see, there is an .each() sentence that is using $(this) inside,
What element will be referenced by $(this) ??? ul li? or iframe? I’m trying, as you can guess, to select each iframe (in the webpage, nothin to do with ul li, there)
I ask this because i am getting unexpected results with a way larger function,
thisrefers to the object of the most specific function scope.If you want to reference the the
ul liversion ofthisfrom inside theiframeinner function, you would have to form a closure around it, like the following: