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

239
Views
How to delete every drawing on canvas javascript?

so in my application when I click on the delete button it's not working. can anyone see the problem?

<button type="button" class="delete">
  <i class="fa-solid fa-trash-can"></i>
</button>
const deleteScreen = () => {
  context.fillStyle = "white";
  context.fillRect(0, 0, canvas.width, canvas.height);
};
deleteAll.addEventListener("onclick", deleteScreen);

to solve this problem, I create a white rectangle. this rectangle has the same height and width as the canvas. when we click on button, it should create rectangle and delete every drawing but it's not doing anything

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try this:

context.clearRect(0, 0, canvas.width, canvas.height);

The clearRect() method sets the pixels in a rectangular area to transparent black (rgba(0,0,0,0)).

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!