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

227
Vistas
jQuery script not working after page is refreshed using pagination or Ajax in WooCommerce

I have written a script to add a mouseover effect on the product archives of my Woocommerce Eshop page. The script works fine when the page is initially loaded. My problem is that when i click Pagination page 2,3,.. or use any Ajax filters the effect is lost. I have found this post that explains that the

ready(function) 

works on page load only, but i am not sure how to make it work on my case. I am adding this script on the head of my WP website.

<script>
jQuery( document ).ready(function() {

///archive page mouseover 
jQuery("li.product-type-simple").mouseover(function(){
jQuery(this).css("box-shadow", "5px 10px 46px #7a7b7c");
 });
jQuery("li.product-type-simple").mouseout(function(){
jQuery(this).css("box-shadow", "unset");
 });
    
jQuery("li.product-type-variable").mouseover(function(){
jQuery(this).css("box-shadow", "5px 10px 46px #7a7b7c");
 });
jQuery("li.product-type-variable").mouseout(function(){
jQuery(this).css("box-shadow", "unset");
});



});
</script>

I need to make the above script work not only when hitting the refresh button but also when using Ajax functionalities like Ajax filters or Woo Commerce pagination.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Please use below script. You've to use following convention to trigger any event on dynamically rendered elements. Thanks :)

jQuery( document ).ready(function() {
   jQuery(document).on("mouseover", "li.product-type-simple", function(){
       jQuery(this).css("box-shadow", "5px 10px 46px #7a7b7c");
   });

   jQuery(document).on("mouseout", "li.product-type-simple", function(){
       jQuery(this).css("box-shadow", "unset");
   });

   jQuery(document).on("mouseover", "li.product-type-variable", function(){
       jQuery(this).css("box-shadow", "5px 10px 46px #7a7b7c");
   });

   jQuery(document).on("mouseout", "li.product-type-variable", function(){
       jQuery(this).css("box-shadow", "unset");
   });

});
over 4 years ago · Santiago Trujillo 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