Very simple jQuery attribute question
<p>Either I have misunderstood <a href="http://api.jquery.com/attr/" rel="nofollow">the jQuery docs for .attr()</a>, or I'm making a very stupid error. </p>

<p>Why isn't this working?</p>

<pre><code>&lt;div id="mydiv" title="mytitle"&gt;&lt;/div&gt;
&lt;script type="text/javascript"&gt;
$(document).ready(function(){ 
    var username = $("#mydiv").attr("title");
    alert(username);
});
&lt;/script&gt;
</code></pre>

<p>I just get 'undefined' in the alert.</p>
