0

タブをクリックするたびに、タブは getPrices() を呼び出します。問題は、クリックするたびに現在のクラスが最初のタブにリセットされることです。これは、load() で proxy.php を呼び出しているためだと思います。

Q: load() が実行された後、クリックされたタブで .addClass('current') を使用するにはどうすればよいですか?

foo.php からのコード

    function getPrices(go) {
        if(go === true) {
        $('div').load('proxy.php5').fadeIn("slow");
        $('div td').animate({
            opacity: 0.7
        }, 200);
        return false;
        }
    };


$('div ul.tab-nav li').click(function(event) {
    getPrices(true);
    $(this).parents('ul').find('li.current').removeClass('current');
    $(this).addClass('current');
    event.preventDefault();
    return false;
}); 

index.php からのコード:

function getPrices(go) {
    if(go === true) {
        $('#spot-prices').load('proxy.php5').fadeIn("slow");
        $('#spot-prices td').animate({
            opacity: 0.7
        }, 200);
    return false;
    }
};
jQuery(document).ready(function() {
    getPrices(true);
});
4

1 に答える 1

0
    function getPrices(go) {
        if(go) {
        $('div').load('proxy.php5').fadeIn("slow");
        $('div td').animate({
            opacity: 0.7
        }, 200);
        return true;
        }
    };


$('div ul.tab-nav li').click(function(event) {
    getPrices(true);
   $('div ul.tab-nav li').removeClass('current');
    $(this).addClass('current');
    event.preventDefault();
    return false;
}); 
于 2012-04-23T10:50:57.867 に答える