开发者

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

开发者 https://www.devze.com 2023-01-06 17:08 出处:网络
This fires the callback twice: $(\'#get_started, #favour\').fadeOut(300, function(){ $(\'#wrap_right\').data(\'first_click_made\', true);

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

精彩评论

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

关注公众号