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

126
Visualizações
Why do wordpress Jquery only work after refresh

This is my code :

<script type="text/javascript">
  jQuery( document ).ready(function() {
    jQuery('#bookbtn_loc_1').on('click', function(event){
      jQuery("a.da-close").click();
      jQuery("#loc").val("B&B de fruithoeve Schalkhoven").change();
    });
  });
</script>

I want to run this code when the button with id #bookbtn_loc_1 is clicked.

But, this script only works after I refresh the page. During the first load, it will not work.

I have tried adding the code on the header and body, but the issue is still there.

I hope there is someone out there who has gone to this issue and solved it already. Please share your solution.

Thank you.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Try with this:

<script type="text/javascript">
    jQuery( document ).ready(function() {
        jQuery( document ).on('click', '#bookbtn_loc_1', function(){
            jQuery("a.da-close").click();
            jQuery("#loc").val("B&B de fruithoeve Schalkhoven").change();
        });
    });
</script>

Remove event parameter from function if it's not needed.

about 4 years ago · Juan Pablo Isaza Relatório

0

i found that there is no button with id "bookbtn_loc_1" exist in your page. So that the script can not bind the click event to the button, so it's not fire.

As you can see in the bellow image, when i find "bookbtn_loc_1" - there are no result: enter image description here

about 4 years ago · Juan Pablo Isaza 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