Javascript 在html中显示警报(或对话框)下拉列表

Javascript 在html中显示警报(或对话框)下拉列表,javascript,jquery,html,css,bootstrap-4,Javascript,Jquery,Html,Css,Bootstrap 4,我的项目要求是在单击按钮时显示警报或对话框,在该警报上,显示带有一些值的下拉列表,选择下拉列表值并使用HTML将其保存在数组列表中。 我试过了,但没用。 警报对话框应如下图所示 启动演示模式 × 模态头 测试 测试 测试 测试 测试 接近 保存更改 请尝试使用 Bootbox附带了一个模式选择下拉列表,请尝试使用它 希望这有帮助试试这段代码 <a data-target="#myModal" role="button" class="btn" data-toggle="modal"&g

我的项目要求是在单击按钮时显示警报或对话框,在该警报上,显示带有一些值的下拉列表,选择下拉列表值并使用HTML将其保存在数组列表中。 我试过了,但没用。 警报对话框应如下图所示


启动演示模式
×
模态头
测试
测试
测试
测试
测试
接近
保存更改
请尝试使用

Bootbox附带了一个模式选择下拉列表,请尝试使用它

希望这有帮助

试试这段代码

<a data-target="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

  <div class="modal-dialog">
  <div class="modal-content">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">Modal header</h3>
  </div>
  <div class="modal-body">
    <select>
              <option>test</option>
              <option>test</option>
              <option>test</option>
              <option>test</option>
              <option>test</option>
          </select>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    <button class="btn btn-primary">Save changes</button>
  </div>
  </div>
  </div>
</div>

这里有一个链接供参考


您已将hide类添加到modal中,并且还丢失了一些代码。请尝试此操作。

您的代码中集成了引导程序吗?在演示链接中,您提供的没有任何错误。我能理解的是,由于试图模仿demo链接中的代码,您可能在不知不觉中推送了一些bug。张贴你的代码,以便它将很容易帮助是的,我已经集成,哪些部分完全不工作?你提供的链接已经有你想要的了!点击按钮,它会显示阴影屏幕而不是警告框。你看不到弹出窗口吗?(或)单击“保存更改”按钮时弹出窗口未关闭?确切的问题是什么?你能解释一下吗。我看不到弹出窗口。可能是js或css问题。。请尝试删除文件中的style.css链接。可能是我添加了错误的js或css文件,请尝试一次,并建议我更改您在jsfiddle.net中提供的代码。没有任何问题。这就是我要求您删除style.css并重试的原因
<a data-target="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

  <div class="modal-dialog">
  <div class="modal-content">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">Modal header</h3>
  </div>
  <div class="modal-body">
    <select>
              <option>test</option>
              <option>test</option>
              <option>test</option>
              <option>test</option>
              <option>test</option>
          </select>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    <button class="btn btn-primary">Save changes</button>
  </div>
  </div>
  </div>
</div>