title: How to change attribute href after click on link and load page JQUERY (Wordpress)?
body: <p>I try to change the URL link (<code>href</code> attribute) when I click on a URL after following link and loading page. I tried this: </p>
  
  <pre><code>&lt;a href="http://example.com/ASC/" class="sort_loading_country"&gt;link&lt;/a&gt;
  </code></pre>
  
  <pre class="lang-js prettyprint-override"><code>jQuery( ".sort_loading_country" ).click(function() {
      str = jQuery(".sort_loading_country").attr("href") ;
      if ((str.indexOf('ASC') + 1) &gt; 0) {
          new_str = str.replace(/ASC/g, "DESC");    
          jQuery(".sort_loading_country").attr("href", new_str);
      }
  });
  </code></pre>
  
  <p>This changes the URL, but after clicking on the link open new page with new url. I want change the URL after opening page and following the link. I tried this too:</p>
  
  <pre><code>jQuery(".sort_loading_country").click(function() {
      str = jQuery(".sort_loading_country").attr("href");
  
      jQuery(document).ready(function() {
          if ((str.indexOf('ASC') + 1) &gt; 0) {
              new_str = str.replace(/ASC/g, "DESC");
              jQuery(".sort_loading_country").attr("href", new_str);
          }
      });
  </code></pre>
  
  <p>The same behavior, click on the link - then open new page with new url. I want that when I click on the link open page with old url and after that change url to new in href.
  Am I missing anything ? Anybody knows how to change attribute href after loading page with old URL ? </p>