<html>
<head>
<script language="javascript" type="text/javascript">
alert(document.getElementById("member").options.length)
</script>
</head>
<body>
<select id="member">
<option value="1"></option>
</select>
</body>
</html>代码报错alert那一句缺少对象是为什么啊?
调试欢乐多
alert(document.getElementById("member").options.length)
//在解析上面这行代码时member的元素还有加载进来
</script>
<head>
<title>this is test</title>
</head>
<body>
<select id="member">
<option value="1"></option>
</select>
<script language="javascript" type="text/javascript">
alert(document.getElementById("member").options.length);
</script>
</body>
</html>
<head>
<script type="text/javascript">
function test()
{
alert(document.getElementById("member").length);
}</script>
</head><body>
<select id="member">
<option>123</option>
</select><input type="submit" onclick="test()" value="show" /></body>
</html>试试