This is already in the area. Just do not var _indexplace functions anywhere or create a local variable with a name _indexthat will take precedence over the variable _indexin the closure.
var _index = $("#sideNewsContent_menu li").index($(this)) + 1;
$("#sideNewsContent_body").fadeOut(300, function (index) {
_index++;
alert(_index);
});
Do not do this:
$("#sideNewsContent_body").fadeOut(300, function (index) {
var _index = _index++;
alert(_index);
});
source
share