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

176
Visualizações
How to link a url to a button in javascript

I am using a WordPress website and trying to attach a url to a button using JavaScript. I have written a function to this, My function as follows.

<div class="the_course_button" data-id="3565"><div class="course_button full button"><a href="https://gutsycreatives.com/course/writing-game-gala/?renew">TAKE THIS COURSE</a></div></div>

  jQuery(document).ready(function ($) {
 $('#3565').each(function() {
  var link = $(this).html();
  $(this).contents().wrap('<a href="https://gutsycreatives.com/product/writing-game-gala/"></a>');
 });
});

I passed my data-id '#3565' to call the function. Now I am getting nothing

What did I do wrong here?

I appreciate the help thanks so much.

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

0

That syntax you are using, is from JQuery, so the error you are getting, is problably because you haven't linked it correctly.

If you want to use JavaScript For making this, you should use document.getElementById("3565")

You will need to change more things if you want to use JavScript, but if you need to use JQuery, you should look this link https://www.w3schools.com/jquery/jquery_get_started.asp

about 4 years ago · Juan Pablo Isaza Relatório

0

I think you should clarify clearly on which environment you get that error. Since I see your tag 'wordpress' so I assume you get the error in wordpress. If so, please read this reference: $ is not a function - jQuery error Your code should be wrapped like this:

jQuery(document).ready(function ($) {
 $('#3565').each(function() {
  var link = $(this).html();
  $(this).contents().wrap('<a href="https://gutsycreatives.com/product/writing-game-gala/"></a>');
 });
});
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