[jQuery] Scope Of Variables Inside Functions
Okay, so first off, I recently started using jQuery, and it is by far
the best and easiest to use/understand framework that I have ever
used. Huge props to the developers and the community! You guys rock!
Anyway, I've read over the jQuery Documentation but I am left a bit
fuzzy as to the whole idea of the scope of variables within functions.
Say I have a variable (x) inside a for loop which is inside my $
(document).ready. If I want to create a function inside my for loop
(like a mouseover event), is it possible to access (x) from inside
this function?
Here is an example to clarify:
--------------------------------------------------------------------
$(document).ready(function(){
// Loop it five times
for(var i = 1; i <= 5; i++){
// Declaring the variable
x = 0;
$(".fade").mouseover(function(){
$(this).fadeTo(10, x);
})
}
}
--------------------------------------------------------------------
Is there some type of shortcode or easy way to access the value of (x)
from within the mouseover function?