Ipython %% javascript magic output to cell and console

How to configure ipythons %%javascriptcellular magic so that it displays both the ipython output cell and the browser console, as shown belowcellmagic

I do not want to use alert(). Also, I tried to get similar behavior with nodejs using %%scriptmagic

%%script node
console.log("Hi")

But that is not what I need.

+4
source share
2 answers

you have access to the output of Dom node under a variable named elementwrapped in jquery. So:

%%javascript
element.text('Hi')
console.log('There')
+5
source

, , , , element.text(), . element.append() javascript %%, . <br> . ,

function assert(cond,msg)
{
   if (!cond)
   {
     element.append(msg + "<br>");
   }
}
+1

All Articles