Last active
July 22, 2016 05:05
-
-
Save jamesbishopca/1864690ce5100de86066 to your computer and use it in GitHub Desktop.
Code toggle button for IPython notebook
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
'''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