I want to change the color the text of the navbar on click
I have this code:
$("a.tab").click(function() {
$("a.tab").css("background-color", "#1F1F1F");
$(this).css("background-color", "#404040");
$("p.name_tab").css("color", "#939393");
$(this).css("color", "white");
});
It change well the background-color of my a balise by not the text inside.
I try this but I need to click again on the text to color it.
$("p.name_tab").click(function() {
$("p.name_tab").css("color", "#939393");
$(this).css("color", "white");
});
CodePudding user response:
change the p.name_tab elements that are inside the a.tab element that was clicked.
$("a.tab").click(function() {
// Change the background color of all a.tab elements
$("a.tab").css("background-color", "#1F1F1F");
// Change the background color of the clicked a.tab element
$(this).css("background-color", "#404040");
// Find the p.name_tab elements inside the clicked a.tab element
$(this).find("p.name_tab").css("color", "white");
// Change the color of all other p.name_tab elements
$("p.name_tab").not($(this).find("p.name_tab")).css("color", "#939393");
});