javascript 问题.

来源:百度知道 编辑:UC知道 时间:2024/09/19 17:02:09
<html>
<head>
<script language="javascripts">
function red(en){
var str = en.length;

alert(str);

}

</script>
</head>
<body>
<form name="f" id ="f">
<select name="sele" >
<option>aaa</option>
<option>ddd</option>
<option>ddfdfff</option>
</select>

</form>
<button onclick="red(sele)">查看</button>

</body>
</html>

提示:sele 未定义. ...
为什么啊 ?
???为什么///
<HTML>
<HEAD>
<TITLE>SELECT对象的属性</TITL

onclick = "red('sele');"

如果要取 sele 的对象的值...最好要有id,不然不兼容非IE浏览器

<select id="sele" name="sele">
....

onclick = "red(document.getElementById('sele'));"

document.getElementById("sele");

function red(en){
var str = en.length;

alert(str);

}
放到下面来定义。