Skip to content

Instantly share code, notes, and snippets.

@alaudet
Created May 29, 2019 11:54
Show Gist options
  • Save alaudet/a7180e37da171d28f5d6f71054a4803a to your computer and use it in GitHub Desktop.
Save alaudet/a7180e37da171d28f5d6f71054a4803a to your computer and use it in GitHub Desktop.
Toggle Code View in Jupyter
# Source: https://stackoverflow.com/questions/27934885/how-to-hide-code-from-cells-in-ipython-notebook-visualized-with-nbviewer
from IPython.display import HTML
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><input type="submit" value="Toggle Code View"></form>''')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment