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

标签 javascript jquery html css bootstrap-4

我的元素要求是在单击按钮时显示警报或对话框,在该警报上显示具有某些值的下拉列表,选择下拉列表值并使用 HTML 将其保存在数组列表中。 我试过this但它不起作用。 警报对话框应如下图所示。

<!-- begin snippet: js hide: false console:

<html lang="en">
 <head>
  <title></title>
 <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
 <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
 <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
 </head>
 <body>

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

<div class="modal fade hide" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <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>
</body>
</html>

最佳答案

试试这个代码...

<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>

https://codepen.io/chandrashekhar/pen/yXNBmQ?editors=1100

这里是引用链接

您已将隐藏类添加到模态并且还遗漏了一些代码试试这个它是否有效..

关于javascript - 在 html 中显示警报(或对话框)的下拉列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44385443/

相关文章:

javascript - 将地址字段复制到帐单地址字段

javascript - 两个日期与今天相比的百分比

javascript - 在 Node.js 中用 fs.createReadStream 替换 fs.readFile

javascript - 替代 <a href ="#"> 当 anchor 标记仅触发 jQuery 操作而不重定向用户时?

javascript - 无法向 DOM 添加元素

javascript - 可以通过脚本获取图像的 CSS 定义大小并在图像加载之前更改 URL 值吗?

javascript - 使用 Gulp-Notify 在终端中显示项目文件夹路径,而不是硬盘上项目的整个路径

javascript - 验证带有字母的指数和十六进制表示法的数值

javascript - 我可以自动提示用户将移动网络应用程序添加到他们的主屏幕吗? [iOS]

javascript - 验证的淡入动画- Angular