In [1]:
from IPython.display import HTML
In [2]:
%%writefile jquery_slide_toggle.html
<script>
$(document).ready(function(){
$("#flip").click(function(){
$("#panel").slideToggle("fast");
});
});
</script>
When the document is ready (loaded and the DOM constrcuted), jQuery will register the click callback on the elements with the #flip id.
In [3]:
%%writefile jquery_slide_toggle.html -a
<style>
#panel, #flip {
padding: 5px;
text-align: center;
background-color: #e5eecc;
border: solid 1px #c3c3c3;
}
#panel {
padding: 50px;
display: none;
}
</style>
In [4]:
%%writefile jquery_slide_toggle.html -a
<div id="flip">Click to slide the panel down or up</div>
<div id="panel">Hello world!</div>
In [5]:
HTML('./jquery_slide_toggle.html')
Out[5]:
In [6]:
%%html
<script>
$(document).ready(function(){
$("#flip0").click(function(){
$("#panel0").slideToggle("fast");
});
});
</script>
<style>
#panel0, #flip0 {
padding: 5px;
text-align: center;
background-color: #e5eecc;
border: solid 1px #c3c3c3;
}
#panel0 {
padding: 50px;
display: none;
}
</style>
<div id="flip0">Click to slide the panel down or up</div>
<div id="panel0">Hello world!</div>