Created
August 26, 2012 14:08
-
-
Save benshimmin/3479885 to your computer and use it in GitHub Desktop.
A definition list accordion in three lines of CoffeeScript with jQuery
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
$("dl.mini-accordion dt").on "click", -> | |
$(@).parent().find("dt, dd").removeClass("is-open") | |
$.each [ $(@), $(@).next() ], (i, e) -> $(e).addClass("is-open") |
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
<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