HTML基础练习|下拉菜单
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>水果选择器</h1>
<label for="favorites">选择你最爱吃的水果</label>
<select id="favorites" name="favorites">
<option value="apple">苹果</option>
<option value="banana">香蕉</option>
<option value="orange">橘子</option>
<option value="grape">葡萄</option>
</select>
<br>
<button onclick="console.error(111)">提交</button>
<script>
function submitSelection() {
let selectedFruit = document.getElementById('favorites').value;
alert('你选择的水果是:' + selectedFruit);
}
</script>
</body>
</html>
原文地址:https://blog.csdn.net/m0_69886881/article/details/142718341
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!