Skip to content

Instantly share code, notes, and snippets.

@igorpronin
Last active August 29, 2015 14:27
Show Gist options
  • Save igorpronin/e406fac8f63bab61809f to your computer and use it in GitHub Desktop.
Save igorpronin/e406fac8f63bab61809f to your computer and use it in GitHub Desktop.
jQuery add / remove / change css class on click
$(".click_element").click(function() {
if ($(".target_element").is(".class_1")) {
$(".target_element").removeClass("class_1");
$(".target_element").addClass("class_2");
} else {
$(".target_element").removeClass("class_2");
$(".target_element").addClass("class_1");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment