html - 如何在html的下拉列表中制作带有一个选定项目的下拉列表
问题描述
当我选择任何一项时,我在下拉列表中有两项,然后只有特定的项目数据来。我想要一个数据默认来。
html
<div class="box-header">
<div class="dropdown" align="left">
<button class="" type="button" data-toggle="dropdown" style="height:22px;" align="center">
<span style="font-size:18px;font-family:sans-serif">Select Water Tank </span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" >
<li><a href="@Url.Action("list", "Watertank" ,new { deviceid="f2"})"><span style="font-size:large">Top</span></a></li>
<li><a href="@Url.Action("list", "Watertank" ,new { deviceid="52"})"><span style="font-size:large">Bottom</span></a></li>
</ul>
</div>
</div>
解决方案
您可以通过将下拉菜单从更改<ul>
为<select>
下面的代码应该默认选择“顶部”
<div class="box-header">
<div class="dropdown" align="left">
<button class="" type="button" data-toggle="dropdown" style="height:22px;" align="center">
<span style="font-size:18px;font-family:sans-serif">Select Water Tank </span>
<span class="caret"></span>
</button>
<select class="bootstrap-select" >
<option selected="selected"><a href="@Url.Action("list", "Watertank" ,new { deviceid="f2"})"><span style="font-size:large">Top</span></a></option>
<option><a href="@Url.Action("list", "Watertank" ,new { deviceid="52"})"><span style="font-size:large">Bottom</span></a></option>
</select>
</div>
</div>
推荐阅读
- r - ggstatsplot:删除 ggwithinstats 中的连线均值
- javascript - 为什么我的魔方计算值减少了 4000?
- python - 如何将 pytest 夹具传递给主函数而不将其添加到参数中?
- python - 在自定义日期对象列表中查找最早日期
- visual-studio - Visual Studio 2022 调试器 JustInTime 安装失败
- docker - AWS EKS EFS 挂载卷。尽管声称的卷中有 21Gi,但 pod 有 8E(EFS 的全部可能大小)
- macos-big-sur - MacOS 系统日志归档
- inno-setup - 尝试在 OneDrive 目录而不是本地用户驱动器中创建文件时出错
- reporting-services - 显示非空记录的计数
- python - os.walk 与 json 文件的多个循环