タブをクリックするたびに、タブは 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);
});