请大神帮我看看 学渣。。
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>定义函数</title>
<script type="text/javascript">
alert(document.getElementsByClassName("sale").length);
</script>
</head>
<body>
<h1>what to buy</h1>
<p title="a gentle reminder">Don't forget to bu this stuff</p>
<ul id="purchases">
<li>aaaaaaa</li>
<li class="sale">bbb</li>
<li class="sale important">milk</li>
</ul>
</body>
</html>
这length为什么提示是0?