It's not exactly a pretty answer, but one approach is simply to assess whether there is, or is not, a next() element and re-call the function or perform a different action:
function elFadeIn(elem) {
elem.fadeIn('slow', function() {
if ($(this).next().length) {
elFadeIn($(this).next());
}
else {
alert('finished');
}
});
}
And a slightly prettier way of writing that would be:
function elFadeIn(elem, callback) {
elem.fadeIn('slow', function() {
var next = $(this).next();,
action = next.length ? elFadeIn(next) : alert('finished!');
});
}
It's not exactly a pretty answer, but one approach is simply to assess whether there is, or is not, a next() element and re-call the function or perform a different action:
function elFadeIn(elem) {
elem.fadeIn('slow', function() {
if ($(this).next().length) {
elFadeIn($(this).next());
}
else {
alert('finished');
}
});
}
And a slightly prettier way of writing that would be:
function elFadeIn(elem, callback) {
elem.fadeIn('slow', function() {
var next = $(this).next();
action = next.length ? elFadeIn(next) : alert('finished!');
});
}
It's not exactly a pretty answer, but one approach is simply to assess whether there is, or is not, a next() element and re-call the function or perform a different action:
function elFadeIn(elem) {
elem.fadeIn('slow', function() {
if ($(this).next().length) {
elFadeIn($(this).next());
}
else {
alert('finished');
}
});
}
And a slightly prettier way of writing that would be:
function elFadeIn(elem, callback) {
elem.fadeIn('slow', function() {
var next = $(this).next(),
action = next.length ? elFadeIn(next) : alert('finished!');
});
}
It's not exactly a pretty answer, but one approach is simply to assess whether there is, or is not, a next() element and re-call the function or perform a different action:
function elFadeIn(elem) {
elem.fadeIn('slow', function() {
if ($(this).next().length) {
elFadeIn($(this).next());
}
else {
alert('finished');
}
});
}
And a slightly prettier way of writing that would be:
function elFadeIn(elem, callback) {
elem.fadeIn('slow', function() {
var next = $(this).next();
action = next.length ? elFadeIn(next) : alert('finished!');
});
}