如何將活動按鈕的文字顏色更改爲白色,並在其他按鈕的文字顏色爲黑色時將其保留爲非活動狀態?如何更改活動按鈕的文字顏色?
<button class="tablink tab" onclick="openPrices('Ladies', this, '#0b0c0d')" id="defaultOpen">Ladies services</button>
<button class="tablink tab1" onclick="openPrices('Mens', this, '#0b0c0d')">Mens services</button>
<button class="tablink tab2" onclick="openPrices('Colour', this, '#0b0c0d')">Colour services</button>
<script>
function openPrices(pricesName, elmnt, color) {
// Hide all elements with class="tabcontent" by default */
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
// Remove the background color of all tablinks/buttons
tablinks = document.getElementsByClassName("tablink");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].style.backgroundColor = "";
}
// Show the specific tab content
document.getElementById(pricesName).style.display = "block";
// Add the specific color to the button used to open the tab content
elmnt.style.backgroundColor = color;
}
// Get the element with id="defaultOpen" and click on it
document.getElementById("defaultOpen").click();
</script>