title: Getting the value from id tag using jQuery
body: <p>I have the below code</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  $(document).ready(function(){
    $("p").click(function(){
      var parts = $('#gitrepo').attr('value'); 
      alert(parts);
      return false;
    });
  });
  &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;p id="gitrepo"&gt;http://github.com/username/repo&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I need extract the value to the parts variable in the script, and split it by '/'. I was able to split it by '/' using .split('/') when i pass a string to parts, like <code>var parts="http://www.github.com",</code> but when i try to take it from the html using the id tag, the alert shows 'undefined' for the value of 'parts'. How can i extract the value between <code>&lt;p&gt;&lt;/p&gt;</code> that has the <code>id"gitrepo"?</code></p>
  
  <p>I tried <code>$('#gitrepo').val();</code> too, but did not work</p>