title: Toggle link HREF
body: <p>I have a menu panel that is displayed via pure css - using <code>#nav</code> - its controlled by a simple button</p>
  
  <pre><code>&lt;a id="nav-burger" href="#nav"&gt;
       &lt;span&gt;&lt;/span&gt;
       &lt;span&gt;&lt;/span&gt;
       &lt;span&gt;&lt;/span&gt;
       &lt;span&gt;&lt;/span&gt;
  &lt;/a&gt;
  </code></pre>
  
  <p>I'd like to toggle the href on click to display <code>#home</code> - can anyone advise how to do this?</p>
  
  <p>I am using this format but my syntax is a bit messed up and there must be an easier way!</p>
  
  <pre><code>$(document).ready(function(){
    $('#nav-burger').click(function(){
      $(this).toggleClass('open');
       $(this).attr('href',$(this).attr('href') == '#nav' ? '#nav' : '#home');
    });
  });
  </code></pre>
  
  <p>Thanks</p>
  
  <p><strong>UPDATE</strong>
  As a demo - In the code snippet below - whenever the link gos red the href should have the value of #home and visa versa fro blue (#nav)</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function(){
    $('#nav-burger').click(function() {
    $(this).toggleClass('open').attr('href', function(_, currHref) {
      return currHref === '#nav' ? '#home' : '#nav';
    });
  });
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>a{color:blue}
  a.open{color:red}</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;a id="nav-burger" href="#nav"&gt;
       
            hello
      
        &lt;/a&gt;</code></pre>
  </div>
  </div>
  </p>