Skip to content

Commit

Permalink
Merge pull request #53 from ViktorSvertoka/buttonfix
Browse files Browse the repository at this point in the history
fix: Filter buttons toggle
  • Loading branch information
ViktorSvertoka authored Dec 17, 2023
2 parents dc4e524 + ca791c4 commit 42bb34e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/js/12-exercises.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import APIService from './00-api';
import icons from '../img/sprite.svg';
const apiService = new APIService();
Expand Down Expand Up @@ -64,4 +63,18 @@ function renderExercises(data) {
})
.join('');
listItem.insertAdjacentHTML('beforeend', markup);
}
}

/**
* Filter buttons toggle
*/
document.addEventListener('DOMContentLoaded', () => {
const buttons = document.querySelectorAll('.exercises__btn');

buttons.forEach(button => {
button.addEventListener('click', () => {
buttons.forEach(btn => btn.classList.remove('active'));
button.classList.add('active');
});
});
});

0 comments on commit 42bb34e

Please sign in to comment.