I had a javascript variable "foo" and a span tag id named "foo" as well. For some reason jQuery seemed like it was confusing the variable for the id if the variable hasn't been declared. So if I wrote the following:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Test</title>
<meta name="author" content="Test">
<script src="js/jquery.min.js"></script>
<!--<script>
var foo = 100;
</script>-->
</head>
<body>
<span id="foo">200</span>
<br>
<hr>
<br>
<p id="test">Foo Value</p>
<script>
$("#test").html(foo);
</script>
</body>
</html>
The html content of #foo gets selected. Is this a feature of jQuery or a bug or just another reason to follow the "DRY" rule?