Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

79
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda