JSドロップダウンリストボックスの要素の数を取得します
コードコピーは次のとおりです。
<!doctype html>
<html>
<head>
<スクリプト>
関数getLength()
{
Alert(document.getElementById( "mySelect")。length); //要素の数
}
</script>
</head>
<body>
<form>
<select id = "mySelect">
<オプション> Apple </option>
<オプション> pear </option>
<オプション>バナナ</option>
<オプション> orange </option>
</select>
<入力型= "ボタン" onclick = "getLength()" value = "リスト内のオプションの数はいくつですか?">
</form>
</body>
</html>