javascript - JQUERY单选按钮弹出

标签 javascript jquery html css jsp

您好,我正在尝试实现带有单选按钮的 jquery 弹出窗口。

这是我的 jquery 函数:

$("#myPopup").ready(function() {

var popUpList = $('<div><input type="radio">A<br><input type="radio">B<br><input type="radio">C</div>');

showPopUpButton.click(function() {
    popUpList.dialog();
});

});

我的jsp页面上各自的html代码:

<ul id="header_navigation">
    <li class="header_navigation_list">
        <a href="home" title="Home" class="header_navigation_link">Home</a>
        <span>|</span>
    </li>

    <li class="header_navigation_list">
        <div data-role="main" class="header_navigation_link">
            <a href="#myPopup" data-rel="popup" class="ui-btn ui-btn-inline ui-corner-all">Show Popup</a>
            <div data-role="popup" id="myPopup">
                <p>This is a simple popup.</p>
            </div>
        </div>
    </li>
</ul>

我的查询是我在 jsp 页面上给出了弹出代码和 ID,但是弹出链接不可见。虽然“主页”链接在网页上可见并且正在运行。我什至在 jsp 页面的顶部包含了 jquery 库。

<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> 

有人可以告诉我在 jsp 页面上声明弹出窗口时我做错了什么吗?时间差

最佳答案

jQuery 弹出窗口也需要样式表 <link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">

在下面找到符合您要求的工作片段:

.radioText {
  margin-left: 45px;
  margin-top: -20px;
  padding: 10px;
}
<!DOCTYPE html>
<html>

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
  <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
  <script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>

<body>

  <ul id="header_navigation">
    <li class="header_navigation_list">
      <a href="home" title="Home" class="header_navigation_link">Home</a>
      <span>|</span>
    </li>

    <li class="header_navigation_list">
      <div data-role="main" class="header_navigation_link">
        <a href="#myPopup" data-rel="popup" class="ui-btn ui-btn-inline ui-corner-all">Show Popup</a>
        <div data-role="popup" id="myPopup" style="min-width:100px;padding:10px;">


          <input type="radio" name="aehe" />
          <div class="radioText">A</div>


          <input type="radio" name="aehe" />
          <div class="radioText">B</div>

          <input type="radio" name="aehe" />
          <div class="radioText">C</div>


        </div>
      </div>
  </ul>

</body>

</html>

关于javascript - JQUERY单选按钮弹出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44462654/

相关文章:

javascript - 过渡效果不起作用jquery

javascript - 如何制作两个 <button> 标签,其中一个触发文本并删除另一个文本?

javascript - 如何在没有 jquery 或需要 main.js 文件的情况下使用 typed.js?

javascript - 通过 jQuery 隐藏两个 Div block 未按预期工作

javascript - JS 等待 .CSS 完成

java - 限制嵌入式 Jetty 中的上传大小

html - 无法在 chrome 中设置表页脚元素的高度

javascript - Chrome 和 Firefox 之间计算的高度不同?

javascript - 当页面已经加载时,如何在使用 javascript 创建元素后选择它?

jquery - 通过 ajax 将 TinyMCE 内容保存为更大表单的一部分