Skip to content

Instantly share code, notes, and snippets.

@steelp2002
Created May 10, 2018 04:59
Show Gist options
  • Save steelp2002/4007011600fcca805c2c514f63cddd97 to your computer and use it in GitHub Desktop.
Save steelp2002/4007011600fcca805c2c514f63cddd97 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/javascript": [
"window.get_element = function(el){\n",
" if(el){$(el).html('')}\n",
" return (el !== undefined) ? el[0] : $('script').last().parent()[0];\n",
"};\n",
"element = undefined;"
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%javascript\n",
"window.get_element = function(el){\n",
" if(el){$(el).html('')}\n",
" return (el !== undefined) ? el[0] : $('script').last().parent()[0];\n",
"};\n",
"element = undefined;"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"application/javascript": [
"var target = get_element(enement)\n",
"$(target).append('<div class=\"hello-world\"> I don\\'t need helper! </div>')"
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%javascript\n",
"var target = get_element(enement)\n",
"$(target).append('<div class=\"hello-world\"> I don\\'t need helper! </div>')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment