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

165
Views
¿Cómo puedo evitar la selección de texto/elemento con el arrastre del cursor?

Hice un control de paginación y noté que al hacer clic en los botones es muy fácil seleccionar accidentalmente las imágenes y el texto individuales. ¿Es posible prevenir esto?

Para aclarar la selección, me refiero a resaltar con el mouse. (Intente arrastrar el mouse de un lado de la pantalla al otro).

Si intenta resaltar el texto o los controles en esta cuadrícula, no podrá seleccionarlos. ¿Cómo se hace eso? Enlace

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

arrastrar y seleccionar tanto inicializar en un evento de mouse hacia abajo como actualizar en movimientos posteriores del mouse. Cuando maneje los eventos para comenzar a arrastrar, o para seguir el mouse, cancele el burbujeo del evento y anule el retorno predeterminado del navegador:

algo como esto en su comienzo arrastrando el mouse hacia abajo y mueva los controladores-

 e=e || window.event; pauseEvent(e);
 function pauseEvent(e){ if(e.stopPropagation) e.stopPropagation(); if(e.preventDefault) e.preventDefault(); e.cancelBubble=true; e.returnValue=false; return false; }
over 4 years ago · Santiago Trujillo Report

0

Para arrastrar, está capturando los eventos mousedown y mousemove . (Y, con suerte, los eventos touchstart y touchmove también, para admitir interfaces táctiles).

Tendrás que llamar a event.preventDefault() tanto en los eventos de down como de move para evitar que el navegador seleccione texto.

Por ejemplo (usando jQuery):

 var mouseDown = false; $(element).on('mousedown touchstart', function(event) { event.preventDefault(); mouseDown = true; }); $(element).on('mousemove touchmove', function(event) { event.preventDefault(); if(mouseDown) { // Do something here. } }); $(window.document).on('mouseup touchend', function(event) { // Capture this event anywhere in the document, since the mouse may leave our element while mouse is down and then the 'up' event will not fire within the element. mouseDown = false; });
over 4 years ago · Santiago Trujillo Report

0

Esta es una publicación muy antigua. Puede que no responda exactamente a esa situación, pero uso CSS para mi solución:

 -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
over 4 years ago · Santiago Trujillo 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!