Skip to content

Instantly share code, notes, and snippets.

@benshimmin
Created August 26, 2012 14:08
Show Gist options
  • Save benshimmin/3479885 to your computer and use it in GitHub Desktop.
Save benshimmin/3479885 to your computer and use it in GitHub Desktop.
A definition list accordion in three lines of CoffeeScript with jQuery
$("dl.mini-accordion dt").on "click", ->
$(@).parent().find("dt, dd").removeClass("is-open")
$.each [ $(@), $(@).next() ], (i, e) -> $(e).addClass("is-open")
<dl class="mini-accordion">
<dt class="is-open">Item 1</dt>
<dd class="is-open>Description 1</dd>
<dt>Item 2</dt>
<dd>Description 2</dd>
<dt>Item 3</dt>
<dd>Description 3</dd>
</dl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment