這是我的射擊游戲的死腳本(按鈕僅用于測試)但出于某種原因我無法弄清楚如何添加 10 而不是 1這就是我現(xiàn)在所擁有的:(function(){ const buttons = document.querySelectorAll('.counterBtn') let count= 0 //Add event listeners and functionailty to each button buttons.forEach(function(button){ button.addEventListener('click', function(){ //buttons if (button.classList.contains('-1')){ count-- } else if (button.classList.contains('+1')){ count++ } else if (button.classList.contains('+10')){ } //Select the counter text const counter = document.querySelector('#counter') counter.textContent = count //dead / alive if (count <= 0 ){ counter.style.color = 'red' console.log("dead") } else if (count > 0){ counter.style.color = 'lightgreen' console.log("alive") } else { counter.style.color = '#000000' } if (count <= 0) { alert ("you died") } else if (count > 100 ) { alert ("u r ful health") } else { return } }) }) })()有人可以幫幫我嗎?
添加多個數(shù)字來計算jquery
慕哥6287543
2022-12-18 18:55:13