Skip to content

Instantly share code, notes, and snippets.

@Lasha
Created February 15, 2012 05:30
Show Gist options
  • Save Lasha/1833510 to your computer and use it in GitHub Desktop.
Save Lasha/1833510 to your computer and use it in GitHub Desktop.
Clicking an element toggles the text of a nested <span> element
$('.EventsToggle td').append("<span>EXPAND</span>")
$('.EventsToggle')
.click(function() {
var $inSpan = $(this).find('span');
$($inSpan).text($inSpan.text() == 'EXPAND' ? 'COLLAPSE' : 'EXPAND');
$(this).next().slideToggle('normal');
})
.next()
.hide();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment