title: Checking href for presence of a query string in jQuery
body: <p>I currently have this bit of jQuery I am using to append a URL with some location information.</p>
  
  <pre><code>jQuery('a').attr('href', function() {
              return this.href + "&amp;location=/123/abc";
         });
  </code></pre>
  
  <p>My issue is most links have a ? in which makes for the use of the above &amp; ok. There are a select few that dont. I am looking to check the url to see if there is a ?. If there is I want to use "&amp;location=/123/abc", if there is no ? I will need to use "?location=/123/abc"</p>
  
  <p>I am not the best with if/else statements. Any help would be appreciated.</p>
  
  <pre><code>if (thereIsA?InTheUrl) {
  
      return this.href + "&amp;location=/123/abc";
  
  } else {
  
      return this.href + "?location=/123/abc";
  
  }
  </code></pre>
  
  <p>Something like that, just not sure oh to write it.</p>