<select id="MySelect" size="10" style="width:500px" >
</select>里面没有<option></option>时,js如何判断?document.getElementById("Myselect")options.lenth > 0 (这么写程序会报 “缺少对象”)jsselect
</select>里面没有<option></option>时,js如何判断?document.getElementById("Myselect")options.lenth > 0 (这么写程序会报 “缺少对象”)jsselect
</select>
<script>
alert(document.getElementById('MySelect').options.length)
</script>
[code=javascript]<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
alert("长度为:"+$("select option").length);
})
</script>
<select></select>[/code]