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

151
Views
How to access returned HTML element

This function defines an HTML element. document.getElementById returns the complete function, not only the h1 element as expected. How I only write what's inside of the two ` (return value).

function tokens() {
        return `
        <h1>test</h1>
    `;
}

document.getElementById('tokens').innerHTML = tokens;
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Change

document.getElementById('tokens').innerHTML = tokens;

to

document.getElementById('tokens').innerHTML = tokens();
about 4 years ago · Juan Pablo Isaza Report

0

You have to call the function with parentheses () in order for it to execute and return the proper output:

document.getElementById('tokens').innerHTML = tokens();
about 4 years ago · Juan Pablo Isaza Report

0

You've written tokens as if it is a variable. Since you want to run a function, add () to tokens. That would be tokens().

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!