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

140
Views
¿Cómo puedo detectar mouseup encima de un elemento cuando el clic comenzó en un elemento diferente?

Estoy tratando de detectar cuándo se suelta el mouse sobre un determinado elemento html. Me gustaría que el evento mouseup se active sin importar dónde comenzó inicialmente el arrastre. Aquí está mi intento, que se comporta de manera muy extraña (a veces se dispara, a veces no, a veces recibo dos alertas):

 $("body").click(function() { $(".cube").mouseup(function() { console.log('mouseup') }); });
 .box, .cube { background: rgb(255, 0, 0); width: 100px; aspect-ratio: 1; display: inline-block; } .cube { background: #222; }
 <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> </head> <body> <div class="box"></div> <div class="cube"></div> </body>

Problema número 2 demostrado: el evento no se activa después de que el arrastre comienza desde el div superior:

 $(".cube").mouseup(function(){ console.log('mouseup') });
 .box{ background: rgb(255, 0, 0); width: 200px; height: 200px; } .cube{ background: #222; width: 200px; height: 200px; }
 <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> </head> <body> <div class="box"></div> <div class="cube"></div> </body>

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

0

Es incluso más simple que lo que hiciste. Solo necesitas

 <script> $(".cube").mouseup(function(){ alert('mouseup') }); </script>

Si lo suelta, significa que ha hecho clic en cualquier lugar antes

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!