Cuando se usa el kernel python3, funciona el siguiente código:
%%js let b = document.createElement("b") b.textContent="Hi there!" element.append("A test:") element.append(b)y sale correctamente
A test:Hi there! con Hi there! siendo audaz.
Sin embargo, cuando cambio al kernel de javascript y ejecuto el código anterior (sin %%js ) obtengo:
evalmachine.<anonymous>:1 let b = document.createElement("b") ^ ReferenceError: document is not defined at evalmachine.<anonymous>:1:9 at Script.runInThisContext (node:vm:129:12) at Object.runInThisContext (node:vm:305:38) at run ([eval]:1020:15) at onRunRequest ([eval]:864:18) at onMessage ([eval]:828:13) at process.emit (node:events:527:28) at emit (node:internal/child_process:936:14) at processTicksAndRejections (node:internal/process/task_queues:84:21)¿Cómo puedo ejecutar con éxito el código cortado cuando uso el kernel js?
No es posible acceder a esos elementos. Sin embargo, es posible lograr el mismo efecto usando $$.html
$$.html('A test:<b>Hi there!</b>')