Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

161
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda