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

80
Vistas
Global JS function Not Available Wordpress - jQuery

My global function is not available because "$ is not a function".

But I do have jquery as a dependency to my own js file:

wp_enqueue_script('common-js', get_stylesheet_directory_uri() . '/js/common.js', array('jquery'), CHILD_THEME_ASTRA_CHILD_VERSION, true);

enter image description here

Why I cannot use jQuery outside of document ready?

almost 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

try out the below code might help you in achieving the result.

jQuery(function($){
    
     function closeOverlay(){
        // Logic Here
     }
     function openOverlay(){
       // Logic Here 
     }

});
almost 4 years ago · Santiago Trujillo Denunciar

0

This will create an anonymous function that will be called immediately ( Immediately Invoked Function Expression or IIFE ) with the $ param and the supplied value for the $ is jQuery. This way, you make sure that all the code inside this can use $ without polluting the global space

(function ($) {
    function whatever(){
        $('.selector').slideUp();
    }

    $(document).ready(function(){
       // some code here
    });
})(jQuery);
almost 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