728x90
반응형
예)
<script>
function setActiveTab(clickedButton) {
const tabButtons = document.querySelectorAll('.tab-button');
const hasClass = clickedButton.classList.contains('VV-tab-button');
tabButtons.forEach(button => {
button.classList.remove('active'); // active 클래스 제거
button.style.backgroundColor = 'white'; //배경색 변경
button.style.color = 'black'; //글자색 변경
});
clickedButton.classList.add('active'); // active 클래스 추가
if (hasClass) {
clickedButton.style.backgroundColor = '#FF6700'; // 주황색
} else {
clickedButton.style.backgroundColor = '#007bff'; // 파란색
}
clickedButton.style.color = 'white'; //글자색 변경
//
}
</script>
728x90
반응형
'CSS' 카테고리의 다른 글
같은 클래스에 아이디 값에 따라 CSS 적용 (0) | 2025.06.10 |
---|---|
[CSS] display 속성- none ,block , inline 차이 (0) | 2022.05.18 |
[CSS] 드래그 (drag) 막기 (1) | 2022.04.27 |