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

122
Views
Acción de activación de jQuery cuando un usuario se desplaza más allá de cierta parte de la página

Hola a todos, necesito una acción jQuery para activar cuando un usuario se desplaza más allá de ciertas ubicaciones en la página. ¿Es esto posible con jQuery? Miré .scroll en la API de jQuery y no creo que esto sea lo que necesito. Se dispara cada vez que el usuario se desplaza, pero necesito que se dispare justo cuando un usuario pasa por un área determinada.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Usa el evento jquery .scroll()

 $(window).on('scroll', function() { var y_scroll_pos = window.pageYOffset; var scroll_pos_test = 150; // set to whatever you want it to be if(y_scroll_pos > scroll_pos_test) { //do stuff } });

http://jsfiddle.net/babumxx/hpXL4/

over 4 years ago · Santiago Trujillo Report

0

Los waypoints en jQuery deberían hacerlo: http://imakewebthings.github.com/jquery-waypoints/

 $('#my-el').waypoint(function(direction) { console.log('Reached ' + this.element.id + ' from ' + direction + ' direction.'); });

Documentación del complemento jQuery waypoints: http://imakewebthings.com/waypoints/guides/jquery-zepto/

over 4 years ago · Santiago Trujillo Report

0

Para activar cualquier acción solo una vez en una sola página, he modificado el fragmento de jondavid de la siguiente manera.

 jQuery(document).ready(function($){ $triggered_times = 0; $(window).on('scroll', function() { var y_scroll_pos = window.pageYOffset; var scroll_pos_test = 150; // set to whatever you want it to be if(y_scroll_pos > scroll_pos_test && $triggered_times == 0 ) { //do your stuff over here $triggered_times = 1; // to make sure the above action triggers only once } }); })


Desplácese hacia abajo hasta Ejecutar fragmento de código

Aquí puede consultar un ejemplo de fragmento de código de trabajo;

 jQuery(document).ready(function($){ $triggered_times = 0; $(window).on('scroll', function() { var y_scroll_pos = window.pageYOffset; var scroll_pos_test = 150; // set to whatever you want it to be if(y_scroll_pos > scroll_pos_test && $triggered_times == 0 ) { alert('This alert is triggered after you have scroll down to 150px') $triggered_times = 1; // to make sure the above action triggers only once } }); })
 p { height: 1000px; }
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <body> <p>scroll down this block to get an alert</p> </body>

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!