Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!