JQuery覆盖不改变无线电选择

时间:2012-09-14 14:46:10

标签: javascript jquery html radio-button

我正在试用jquery-overlay-example但是用单选按钮。所以在页面加载后,我可以进行选择,但我不能将我的选择更改为其他选项。我的代码在这里:

<!DOCTYPE html>
<html>

<head>
  <title>jQuery Tools standalone demo</title>

    <!-- include the Tools -->
  <script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>

  <style>
    .modal {
    background-color:#fff;
    display:none;
    width:350px;
    padding:15px;
    text-align:left;
    border:2px solid #333;

    opacity:0.8;
    -moz-border-radius:6px;
    -webkit-border-radius:6px;
    -moz-box-shadow: 0 0 50px #ccc;
    -webkit-box-shadow: 0 0 50px #ccc;
  }

  .modal h2 {
    margin:0px;
    padding:10px 0 10px 45px;
    border-bottom:1px solid #333;
    font-size:20px;
  }
  </style>
</head>
<body><!-- the triggers -->
<p>

  <input type="radio" name="group1" value="Milk" class="modalInput" rel="#yesno"> Milk<br>
<input type="radio" name="group1" value="Butter" class="modalInput" rel="#yesno"> Butter<br>
<input type="radio" name="group1" value="Cheese" class="modalInput" rel="#yesno"> Cheese
</p>

<!-- yes/no dialog -->
<div class="modal" id="yesno">
  <h2>This is a modal dialog</h2>

  <p>
    You can only interact with elements that are inside this dialog.
    To close it click a button or use the ESC key.
  </p>

  <!-- yes/no buttons -->
  <p>
    <button class="close"> Yes </button>
    <button class="close"> No </button>
  </p>
</div>

<!-- user input dialog -->
<div class="modal" id="prompt">
  <h2>This is a modal dialog</h2>

  <p>
    You can only interact with elements that are inside this dialog.
    To close it click a button or use the ESC key.
  </p>

  <!-- input form. you can press enter too -->
  <form>
    <input />
    <button type="submit"> OK </button>
    <button type="button" class="close"> Cancel </button>
  </form>
  <br />

</div>

<script>
$(document).ready(function() {
    var triggers = $(".modalInput").overlay({

      // some mask tweaks suitable for modal dialogs
      mask: {
        color: '#ebecff',
        loadSpeed: 200,
        opacity: 0.9
      },

      closeOnClick: false
  });   
  });
</script>
</body>
</html>

请原谅我,如果这是一个简单的问题,我对JQuery相对较新。

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

试试这个 - DEMO

$(document).ready(function() {
    var triggers = $(".modalInput").overlay({
        mask: {
            color: '#ebecff',
            loadSpeed: 200,
            opacity: 0.9
        },

        closeOnClick: false,

        onClose: function() {
            this.getTrigger().prop('checked', true);
        }
    });   
});