ここに jQuery を使用するページがあります: http://treethink.com/services 私がしようとしているのは、そこにスライドまたはサブページが表示されている場合、背景色とボタンの色を変更することです。
これを行うために、特定の div が表示されている場合、特定のボタンの背景色が変わると言ってみました。ただし、正しく機能していないことがわかります。Web の色を変更していますが、ページを変更したときに色の変更を削除したり、別のボタンに色の変更を追加したりしていません。
全体的なコードは次のとおりです。
/* Hide all pages except for web */
$("#services #web-block").show();
$("#services #print-block").hide();
$("#services #branding-block").hide();
/* When a button is clicked, show that page and hide others */
$("#services #web-button").click(function() {
$("#services #web-block").show();
$("#services #print-block").hide();
$("#services #branding-block").hide();
});
$("#services #print-button").click(function() {
$("#services #print-block").show();
$("#services #web-block").hide();
$("#services #branding-block").hide();
});
$("#services #branding-button").click(function() {
$("#services #branding-block").show();
$("#services #web-block").hide();
$("#services #print-block").hide();
});
/* If buttons are active, disable hovering */
if ($('#services #web-block').is(":visible")) {
$("#services #web-button").css("background", "#444444");
$("#services #web-button").css("color", "#999999");
}
if ($('#services #print-block').is(":visible")) {
$("#services #print-button").css("background", "#444444");
$("#services #print-button").css("color", "#999999");
}
if ($('#services #branding-block').is(":visible")) {
$("#services #branding-button").css("background", "#444444");
$("#services #branding-button").css("color", "#999999");
}
ありがとう、
ウェイド