Created
August 11, 2013 18:47
-
-
Save siriokun/6206289 to your computer and use it in GitHub Desktop.
Toggle
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
/** | |
* Toggle | |
*/ | |
body{ | |
background: #111; | |
} | |
.container{ | |
background: #fff; | |
margin:0 auto; | |
padding: 10px; | |
width: 300px; | |
} | |
#more-less-button{ | |
display: block; | |
margin: 0 auto; | |
padding: 10px | |
} |
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
<div class="container"> | |
<button id="more-less-button" onclick="toggleHelpBox()" jsdisplay="more" jsvalues=".moreText:more; .lessText:less;" jscontent="more" jstcache="4">Less</button> | |
<div id="help-box-outer" class="hidden" jstcache="0"> | |
The contents of this text is only an example for you to see. | |
</div> | |
</div> |
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 toggleHelpBox() { | |
var helpBoxOuter = document.getElementById('help-box-outer'); | |
helpBoxOuter.classList.toggle('hidden'); | |
var moreLessButton = document.getElementById('more-less-button'); | |
if (helpBoxOuter.classList.contains('hidden')) { | |
moreLessButton.innerText = moreLessButton.moreText; | |
} else { | |
moreLessButton.innerText = moreLessButton.lessText; | |
} | |
} |
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
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment