So, I'm working on teaching myself jQuery with the help of some books, and I'm currently stumped by a seemingly simple problem. Why does the value of $('div.foo').length evaluate to 0? A div element exists in the page, so why doesn't the $('div.foo').length evaluate to 1?
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js" type="text/javascript">
</script>
<script type="text/javascript">
document.write($(div.foo).length);
</script>
<body>
<div class="foo"></div>
</body>
</html>