Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

160
Vistas
How to access document and element variable when using javscript kernel

When using the python3 kernel the following code works:

%%js
let b = document.createElement("b")
b.textContent="Hi there!"
element.append("A test:")
element.append(b)

and correctly outputs

A test:Hi there!

with Hi there! being bold.

However, when I switch to the javascript kernel and run the above code (without %%js) I get:

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)

How can I successfully run the code snipped when using the js kernel?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It is not possible to access those elements. However, it is possible to achieve the same effect using $$.html

$$.html('A test:<b>Hi there!</b>')
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda