title: jQuery get last part of URL
body: <p>I have a series of pages where I need to get a specific code for a button.
  I want to put the code which is in the url into a variable with jQuery.</p>
  
  <p>An example URL is www.example.com/folder/code/12345/</p>
  
  <p>I want to get the number part in a variable called (siteCode)</p>
  
  <p>Thanks in advance for any answers.</p>
  
  <p>jquery / Pseudo code:</p>
  
  <pre><code>var siteCode;
  
  // start function
  function imageCode(){
       siteCode // equals number part of URL
       $('.button').attr('src', 'http:www.example.com/images/'+siteCode+'.jpg');
  }
  </code></pre>