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

177
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 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