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

123
Views
How do I access a functions' property in Javascript?

So I am new to Javascript and I wanted to know how I should append the variable red_btn to my document. The code currently does not work. I am not used to using functions so is my code correct. I wanted to make a few more buttons in Buttons() function. Please help me out.

function CreateCircle(r, color){
    let canvas = document.getElementById("MyCanvas");
    let ctx = canvas.getContext("2d");
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    ctx.beginPath()
    ctx.arc(240, 200, r, 0 , 2 * Math.PI);
    ctx.fillStyle = color;
    ctx.stroke();
    ctx.fill();
}

function Buttons(){
    const red_btn = document.createElement("button");
    red_btn.innerHTML = "Button";
    red_btn.name = "red_btn";
    red_btn.type = "button";
    red_btn.innerText = "Red";
}

document.body.appendChild(Buttons.red_btn);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It should be just the following:

function Buttons(){
    const red_btn = document.createElement("button");
    red_btn.innerHTML = "Button";
    red_btn.name = "red_btn";
    red_btn.type = "button";
    red_btn.innerText = "Red";

    return red_btn;
}
    
document.body.appendChild(Buttons());
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!