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

176
Views
Vincular un solo controlador de eventos a múltiples eventos con jQuery

Tengo el siguiente div con diferentes funciones para onblur, onmousedown, onmouseup y onfocus. Quiero minimizar el código y tener solo una llamada de función dentro de div para todos los estados de función. Quiero hacer esto con jquery Entonces, en otras palabras. Quiero crear una función llamada functionAll y poner toda la función 1 en la función 4 con el estado del mouse adentro, luego solo use functionAll dentro de Div. ¿Cómo puedo hacer algo como esto?

 <div contentEditable="true" onblur="function1();" onmousedown="return function2(event);" onmouseup="function3();" onfocus="function4();"> test test </div>
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Debe poner una identificación en el div, decir "prueba", luego:

 $('#test').bind('blur mousedown mouseup focus', function (e) { // This is your combined function // Inside here you can use e.type to find out whether it was a // "blur", "mousedown", "mouseup", etc... });

El HTML se verá así:

 <div id="test" contentEditable="true"> test test </div>
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!