基本的にクラススワップをしたいリンクがいくつかあります。私がそれを次のように設定すると、それはずっと実行されます:
$("#work").click(function() {
$(".nav_middle_text").removeClass("selected");
$(".nav_middle_text").addClass("notselected");
$(this).removeClass("notselected");
$(this).addClass("selected");
a1=1;
$("#top_section").animate({
height:30
},450);
$("#bottom_section").animate({
height:$("#grid").outerHeight(true)
}, 450);
$("#about_container").animate({
marginTop:$("#about_container").outerHeight(true) *-1
}, 450);
});
しかし、このように設定しようとすると、特定のクラスで最初の2つの追加クラスと削除クラスが実行されますが、「this」を使用する次の2つは機能しません。このように実行すると、「これ」が機能しなくなる理由はありますか?
function nav_click() {
$(".nav_middle_text").removeClass("selected");
$(".nav_middle_text").addClass("notselected");
$(this).removeClass("notselected");
$(this).addClass("selected");
}
$("#work").click(function() {
nav_click();
a1=1;
$("#top_section").animate({
height:30
},450);
$("#bottom_section").animate({
height:$("#grid").outerHeight(true)
}, 450);
$("#about_container").animate({
marginTop:$("#about_container").outerHeight(true) *-1
}, 450);
});
助けてくれてありがとう