How to insert hyperlink via jQuery

How to insert hyperlink via jQuery

How can I define a hyperlink as a variable and insert it into the a href using jQuery? The reason for this is that our lead management system is automatically appending all hyperlinks causing some of those with specific URL parameters to break. Here is what I have so far, which I know is a mess:

  1. <script>
  2. function linkHigh) {
  3.     var str = "high temps";
  4.     var finalLink= str.link("https://www.weather.com?bref=abcdefg#hightemps");
  5.     document.getElementById("highTemps").innerHTML = finalLink;
  6. }
  7. </script>

  8. <a id="highTemps" href=""onclick="linkHigh()"></a>