Created
August 16, 2013 05:28
-
-
Save thirdj/6247530 to your computer and use it in GitHub Desktop.
jquery accordion
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script> | |
| <meta charset=utf-8 /> | |
| <title>JS Bin</title> | |
| <style> | |
| dl {} | |
| dd { margin: 0; padding: 0.5em 0; padding-left: 10px; } | |
| dt { | |
| cursor: pointer; font-weight: bold; line-height: 2em; background: #F2F2F2; | |
| border-bottom: 1px solid #c5c5c5; border-top: 1px solid #fff; padding-left: 10px; | |
| } | |
| dt:first-child { border-top: none; } | |
| dt:last-child { border-bottom: none; } | |
| .hide { display: none; } | |
| </style> | |
| </head> | |
| <body> | |
| <dl> | |
| <dt>R</dt> | |
| <dd>2222</dd> | |
| <dt>3333</dt> | |
| <dd>4444</dd> | |
| <dt>5555</dt> | |
| <dd>6666</dd> | |
| </dl> | |
| <script> | |
| $(function(){ | |
| $('dd').addClass('hide'); | |
| $('dl').on('click','dt',function(){ | |
| if($(this).next().css('display') == 'block'){ | |
| $(this).next().slideUp(200); | |
| return false; | |
| } | |
| $(this).next().slideDown(200).siblings('dd').slideUp(200); | |
| }); | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment