Skip to content

Instantly share code, notes, and snippets.

@simeonf
Created May 9, 2016 18:08
Show Gist options
  • Save simeonf/aceb8c3b3fea7e443a16d95336d57f73 to your computer and use it in GitHub Desktop.
Save simeonf/aceb8c3b3fea7e443a16d95336d57f73 to your computer and use it in GitHub Desktop.
First cell in my IPython Notebook to add hidden cells with a "Show" button.
# hideme
import IPython.core.display as di
di.display_html("""<script>$(function() {
$("div.code_cell:contains('hideme')").hide();
$("div.code_cell:contains('showme')").hide();
$(".showme").remove();
$("div.code_cell:contains('showme')").before('<button class="showme">Show Answer</button>');
$(".showme").click(function(){$(this).next().show();});
});</script>""", raw=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment