Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
Cómo vincular una url a un botón en javascript

Estoy usando un sitio web de WordPress e intento adjuntar una URL a un botón usando JavaScript. He escrito una función para esto, Mi función de la siguiente manera.

 <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>'); }); });

Pasé mi ID de datos '#3565' para llamar a la función. ahora no obtengo nada

¿Qué hice mal aquí?

Agradezco la ayuda muchas gracias.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Esa sintaxis que está utilizando es de JQuery, por lo que el error que está recibiendo probablemente se deba a que no la ha vinculado correctamente.

Si quiere usar JavaScript para hacer esto, debe usar document.getElementById("3565")

Deberá cambiar más cosas si desea usar JavScript, pero si necesita usar JQuery, debe consultar este enlace https://www.w3schools.com/jquery/jquery_get_started.asp

about 4 years ago · Juan Pablo Isaza Report

0

Creo que debería aclarar claramente en qué entorno obtiene ese error. Como veo su etiqueta 'wordpress', supongo que obtiene el error en wordpress. Si es así, lea esta referencia: $ no es una función - error de jQuery Su código debe estar envuelto así:

 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!