开发者

jquery problem: callback is fired for each selector (ie 3 selectors, fired three times)

This fires the callback twice:

$('#get_started, #favour').fadeOut(300, function(){
    $('#wrap_right').data('first_click_made', true);
    setup_tab_1(id);
    load_fb_js();               
});

this doesn't but is it the best way to fix the problem?

$('#wrap_right #favour').fadeOut(300);
$('#get_started').fadeOut(300, function(){
    $('#wrap_right').data('first_click_made', tr开发者_运维知识库ue);
    setup_tab_1(id);
    load_fb_js();               
});


An alternative:

$('#get_started, #favour').fadeOut(300, function(){
    if (this.id === 'get_started')
    {
        $('#wrap_right').data('first_click_made', true);
        setup_tab_1(id);
        load_fb_js();               
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜