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

175
Views
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 answers
Answer question

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 Report

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