Skip to content

Instantly share code, notes, and snippets.

@unfulvio
Created June 17, 2013 14:33
Show Gist options
  • Save unfulvio/5797327 to your computer and use it in GitHub Desktop.
Save unfulvio/5797327 to your computer and use it in GitHub Desktop.
Make every <dd> (definition description) element in a <dl> (definition llist) toggleable by the <dt> (definition term) element. Useful for creating toggleable lists, FAQs lists, etc.
$('#dl-container-id').on('click', 'dt.class-name', function() {
$(this).next().toggle();
});
/** collapses the dd element in the dt-toggleable definition list by default **/
#dl-container-id dd.class-name { display: none }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment