100-project-100-days-website/100_projects/73-like-and-dislike-using-javascript/main.js
2023-05-05 13:51:37 +03:00
Ask

28 lines
670 B
JavaScript

{1461462d29ad288cb0eac9a426059858dfcd1079 true 670 main.js 0xc001de1880}

(function(){
const buttons = document.querySelectorAll('.btn');
let count = 0;
buttons.forEach(function(button){
button.addEventListener('click', function(){
if(button.classList.contains('prevBtn')){
count--
}
else if(button.classList.contains('nextBtn')){
count++
}
const counter = document.querySelector("#counter");
counter.textContent = count
if(count < 0){
counter.style.color = 'red'
}
else if(count > 0){
counter.style.color = "green"
}
else{
counter.style.color = "#333333"
}
})
})
// statements
}) ()