Skip to content

Instantly share code, notes, and snippets.

@mattradford
Created June 8, 2015 09:47
Show Gist options
  • Save mattradford/3c689480381eedaf281a to your computer and use it in GitHub Desktop.
Save mattradford/3c689480381eedaf281a to your computer and use it in GitHub Desktop.
jQuery toggle multiple divs independently with text change
$(".event-more-control").click(function(e) {
e.preventDefault(); // prevent default click event
$(this).toggleClass('active');
$(this).parentsUntil('event-index-details').children(".event-excerpt").slideToggle(500);
$(this).children(".link-text").text(function(i, oldText) {
return oldText === 'More' ? 'Less' : 'More';
});
});
@existemjon
Copy link

Great code, super simple – thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment