Skip to content

Instantly share code, notes, and snippets.

@softiconic
Last active December 2, 2023 18:34
Show Gist options
  • Save softiconic/b8b851c5ad09bf5da31bcb60856ae5c4 to your computer and use it in GitHub Desktop.
Save softiconic/b8b851c5ad09bf5da31bcb60856ae5c4 to your computer and use it in GitHub Desktop.
Add or remove a class in a section-based loop for multiple items.
$(document).ready(function() {
$('.scshow').click(function() {
var parentDiv = $(this).closest('.scteto');
if (parentDiv.hasClass('highlighted')) {
parentDiv.removeClass('highlighted');
} else {
parentDiv.addClass('highlighted');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment