title: jQuery remove string from string doesn't work
body: <p>Everytime an certain image is clicked I fetch some information, to add that information to a string and after that replace the current url with the new one. This is my code so far:</p>
  
  <pre><code> jQuery(document).ready(function(){
      var kleuren = [];
      jQuery('.swatch-category-container img').click(function(){
  
  
          var kleur = jQuery(this).attr('title');
          console.log("Selected kleur: " + kleur);
          var link = jQuery(this).closest('.popup').find('.photo a').prop('href');
          kleuren.push(kleur);
          console.log(kleuren);
          console.log(kleuren.length);
          console.log("Fetched link: " + link);
          var length = kleuren.length -1;
          var avoid ="?kleur="+kleuren[length];
  
          console.log("Remove string: " + avoid);
  
          var news_link = link.replace(avoid,'');
          var new_link = news_link + "?kleur="+kleur;
  
          console.log("Cut string: " + news_link);
  
          jQuery('.photo').find('.sendkleur').attr("href", new_link);
  
  
      });
  });
  </code></pre>
  
  <p>This works fine, but the previous data doesn't get removed.</p>
  
  <p>For example
  <br>
  When the first image is clicked the <code>kleur = zwart</code> that info is put in the url. <br>
  But when the user clicks another image after that the url will look like <code>?kleur=zwart?kleur=beige</code> instead just of <code>?kleur=beige</code> </p>
  
  <p>How can I remove the first part?</p>