function within function not working
I have the following script:
$('li.cat-hider').click(function () {
var activeID = $(this).attr('id');
if ($('li#' + activeID).hasClass('hidethis')) {
$('img.t-' + activeID).toggleClass('hidden', function () {
alert('ok');
});
$(this).toggleClass('hidethis');
$('img.t-' + activeID).slideToggle('slow');
} else {
$(this).toggleClass('hidethis');
$('img.t-' + activeID).toggleClass('hidden').s开发者_StackOverflowlideToggle('slow');
}
});
The alert doesn't occur. Everything else toggles and works fine. I can't understand why the alert won't happen. Can someone please point out to me where I'm going wrong?
MTIA!
ToggleClass has no callback. See the docs. You shouldn't need one either because the class toggle occurs instantly.
精彩评论