Skip to content

Instantly share code, notes, and snippets.

@dejurin
Created March 12, 2024 21:48
Show Gist options
  • Save dejurin/d5c5deaf127ddb595e0a3c28907cbe0f to your computer and use it in GitHub Desktop.
Save dejurin/d5c5deaf127ddb595e0a3c28907cbe0f to your computer and use it in GitHub Desktop.
// https://jsfiddle.net/v8Lxazhr/
function changeValue(isIncreasing) {
const valueElement = document.getElementById('valueElement');
let currentValue = parseInt(valueElement.innerText);
if (isIncreasing) {
currentValue++;
valueElement.style.color = 'green';
} else {
currentValue--;
valueElement.style.color = 'red';
}
valueElement.innerText = currentValue;
setTimeout(() => {
valueElement.style.color = '';
}, 500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment