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

216
Vistas
How to detect before dropped selected text into input

As usual you can drop selected text from anywhere into inputs. I want to do something when cursor into an input. ex: if I selected some text then I dragged into an input, but I don't dropping into that input. But input making the cursor and the cursor icon has been changed to plus icon, I want to do function at that time!

enter image description here


$("input").on("beforeDROP", function(){
//do something
});
    form input {
        font-size: 16px;
    }

    form {
        margin: 0 auto;
        width: 100%;
        text-align: center;
    }
    <form>
        <p>some text</p>
        <input type="text" />
    </form>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use the dragover and dragstart events to listen for these events.

Attaching a dragstart listener to the document will fire whenever any selected text is dragged on the page.

If you add a dragover listener to your text input you'll be able to detect when the selected text is being dragged over it:

let textInput = document.getElementById('text-input');

textInput.addEventListener("dragover", (event) => {
  // prevent default to allow drop
  event.preventDefault();
  
  console.log('dragging over input');
}, false);


document.addEventListener("dragstart", (event) => {
  console.log('dragging');
}, false);
form input {
  font-size: 16px;
}

form {
  margin: 0 auto;
  width: 100%;
  text-align: center;
}
<form>
  <p>some text</p>
  <input type="text" id="text-input" />
</form>

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