title: How do you change/modify certain parts of multiple hrefs on keyup using jquery?
body: <p>I have a single input with a value set. </p>
  
  <p>I have 2/multiple a tags with 2 different hrefs set with the first set input value</p>
  
  <p>If I change the input on keyup, I want to only change/modify only the previous set value and keep the rest of the href the same except the previous value. 
  I have a fiddle of this, it is sort of working but not well, Im doing something wrong here. 
  Any help or advice would be apreciated.
  <a href="https://jsfiddle.net/nlstm/do6eL1z4/1/" rel="nofollow noreferrer">https://jsfiddle.net/nlstm/do6eL1z4/1/</a></p>
  
  <pre><code>&lt;input id="MYinput" type="text" value="test"&gt;&lt;/input&gt; 
  
  &lt;br&gt;&lt;br&gt;
  &lt;a id="w3s" href="https://www.example1.com?q="&gt;Test1&lt;/a&gt;
  &lt;br&gt;
  &lt;a id="w3s" href="https://www.example2.com?q="&gt;Test2&lt;/a&gt;
  &lt;br&gt;&lt;br&gt;
  
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  
  
  var OriginalValue = $("#MYinput").val(); 
  
  $('a#w3s').each(function(){
  
      var allHrefs = $(this).attr("href");
  
      var FinalHrefs = allHrefs + OriginalValue;
  
      var CompleteHrefs = $(this).attr("href",FinalHrefs)
  
  
  });
  
  
  
  
  
  $('#MYinput').keyup(function(){  
  
  var textFromInput = $("#MYinput").val();   
  
  $('a#w3s').each(function(){
  
  
      var urlKey = $(this).prop("href").split(OriginalValue)[0];
  
      var FinalHref = urlKey + textFromInput;
  
      var CompleteFinal = $(this).attr("href",FinalHref)
  
  
  });
  
  });
  
  
  
  
  
  &lt;/script&gt;
  </code></pre>