Skip to content

Instantly share code, notes, and snippets.

@ervinne13
Created February 3, 2019 06:53
Show Gist options
  • Save ervinne13/83156a2c23087cc08d666e85258bbc01 to your computer and use it in GitHub Desktop.
Save ervinne13/83156a2c23087cc08d666e85258bbc01 to your computer and use it in GitHub Desktop.
Refactoring JavaScript: Separation of Concerns - Styles on JS (Fixed)
function toggleFooHasError() {
let foo = document.getElementById('foo');
if (foo.classList.contains('has-error')) {
foo.classList.remove('has-error');
} else {
foo.classList.add('has-error');
}
}
toggleFooHasError();
// all styling must be done in css, just assign a class to it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment