Created
July 9, 2012 19:01
-
-
Save jamesflorentino/3078240 to your computer and use it in GitHub Desktop.
Table sibling
This file contains 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
<link href="style.css" rel="stylesheet" /> | |
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script> | |
<script src="script.js"></script> | |
<table class="format2" > | |
<thead> | |
<tr> | |
<td>Toggle visibility</td> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin porttitor rhoncus bibendum. Nunc sed enim a lacus tincidunt consequat. </td> | |
</tr> | |
</tbody> | |
</table> | |
<table class="format2" > | |
<thead> | |
<tr> | |
<td>Toggle visibility</td> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin porttitor rhoncus bibendum. Nunc sed enim a lacus tincidunt consequat. </td> | |
</tr> | |
</tbody> | |
</table> | |
<table class="format2" > | |
<thead> | |
<tr> | |
<td>Toggle visibility</td> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin porttitor rhoncus bibendum. Nunc sed enim a lacus tincidunt consequat. </td> | |
</tr> | |
</tbody> | |
</table> | |
<table class="format2" > | |
<thead> | |
<tr> | |
<td>Toggle visibility</td> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin porttitor rhoncus bibendum. Nunc sed enim a lacus tincidunt consequat. </td> | |
</tr> | |
</tbody> | |
</table> |
This file contains 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
function ready() { | |
$('table > thead') | |
.each(function(e){ | |
$(this).siblings(':last').hide(); | |
}) | |
.click(function(e) { | |
$(this).siblings(':last').toggle(); | |
}); | |
} | |
$(ready); |
This file contains 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
body { background: #eee; color: #111; font-family: Helvetica Neue, Helvetica, sans-serif; } | |
table { | |
background: #ccc; | |
border: 1px solid #aaa; | |
width: 200px; | |
} | |
table thead { | |
font-size: 18px; | |
cursor: pointer; | |
user-select: none; | |
-webkit-user-select: none; | |
-moz-user-select: none; | |
-o-user-select: none; | |
} | |
table thead:hover { | |
background: rgba(1,1,1,0.1); | |
} | |
table tbody { | |
font-size: 12px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment