Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

241
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda