<body>
<p>
请选择菜单:
<select id=‘menu‘>
<option>请选择</option>
<option value="fruit">水果</option>
<option value="cake">蛋糕</option>
<option value="nuts">坚果</option>
</select>
</p>
<p>该系列有:<span></span></p>
<script>
var menu=document.getElementById(‘menu‘);
var options=menu.querySelectorAll(‘option‘);
var Myspan=document.querySelector(‘span‘);
for(var i=0;i<options.length;i++){
menu.onchange=function(){
console.log(this.value)
switch (this.value){
case ‘fruit‘:
Myspan.innerHTML=‘水果‘;
break;
case ‘cake‘:
Myspan.innerHTML=‘蛋糕‘;
break;
case ‘nuts‘:
Myspan.innerHTML=‘坚果‘;
break;
}
}
}
</script>
</body>