Created
June 8, 2015 09:47
-
-
Save mattradford/3c689480381eedaf281a to your computer and use it in GitHub Desktop.
jQuery toggle multiple divs independently with text change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".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'; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great code, super simple – thanks