Skip to content

Instantly share code, notes, and snippets.

@jamesbishopca
Last active July 22, 2016 05:05
Show Gist options
  • Save jamesbishopca/1864690ce5100de86066 to your computer and use it in GitHub Desktop.
Save jamesbishopca/1864690ce5100de86066 to your computer and use it in GitHub Desktop.
Code toggle button for IPython notebook
'''Creates a button to toggle code inputs on and off.'''
from IPython.core.display import display_html
di.display_html('''
<script>
'use strict';
function code_toggle() {
let code = $('div.input');
code.css('display') == 'none' ? code.show() : code.hide();
}
$(document).ready(function() {
$('div.input').hide();
});
</script>
''', raw=True)
di.display_html('<button onclick="code_toggle()">Toggle Code</button>', raw=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment