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

246
Views
¿Opuesto a ondragover en javascript?

Estoy creando una aplicación de arrastrar y soltar para la cual el usuario arrastra un archivo a un div. Cuando el archivo que se está arrastrando está sobre el div, el div se vuelve verde.

 var dropzone = document.querySelector(".dropzone"); dropzone.ondragover = event => { event.target.classList.add("fileover"); };
 .dropzone { border: 1px solid lightgray; padding: 2rem; margin: 2rem; border-radius: 10px; font-family: Arial; cursor: pointer; text-align: center; font-size: 0.8rem; } .fileover { background-color: green; }
 <input id="file" type="file" style="display: none"/> <label for="file"> <div class="dropzone" ondrop="event.preventDefault()">Drag and drop or select a file</div> </label>

Pero digamos que el usuario decide no colocar el archivo en la zona de colocación y aleja el archivo de la zona de colocación. En ese caso, la zona de lanzamiento permanece verde. Entonces, ¿hay un evento que se activa cuando el archivo sale de la zona de colocación, entonces, la zona de colocación vuelve a ser blanca? ¿Algo así como ondragaway ?

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

0

Podrías usar ondragleave :

Tenga en cuenta que también reemplazo ondragover con ondragenter por coherencia.

 var dropzone = document.querySelector(".dropzone"); dropzone.ondragenter = event => { event.target.classList.add("fileover"); }; dropzone.ondragleave = event => { event.target.classList.remove("fileover"); };
 .dropzone { border: 1px solid lightgray; padding: 2rem; margin: 2rem; border-radius: 10px; font-family: Arial; cursor: pointer; text-align: center; font-size: 0.8rem; } .fileover { background-color: green; }
 <input id="file" type="file" style="display: none"/> <label for="file"> <div class="dropzone" ondrop="event.preventDefault()">Drag and drop or select a file</div> </label>

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!