第一次点击后点击事件没有触发

Click event not firing after first click

使用 jquerymobile 1.4.5

我有一系列单选按钮

        <fieldset data-role="controlgroup" data-type="horizontal">
          <legend>Condition (handles etc.):</legend>
          <input name="radio-choice-h-28" id="radio-choice-h-28a" value="1" type="radio">
          <label for="radio-choice-h-28a">Satisfactory</label>
          <input name="radio-choice-h-28" id="radio-choice-h-28b" value="2" type="radio">
          <label for="radio-choice-h-28b">Unsatisfactory</label>
          <input name="radio-choice-h-28" id="radio-choice-h-28c" value="0" type="radio">
          <label for="radio-choice-h-28c">Not Applicable</label>
        </fieldset>

和两个按钮

  <form>
    <input id="set" data-inline="true" value="Save" type="button">
    <input id="reset" data-inline="true" value="Reset" type="button">
  </form>

事件已附加在文档准备区

<script type="text/javascript">
$(document).ready(function () {
$("#set").click(function() {
$('#radio-choice-h-28a').attr("checked", true).checkboxradio("refresh");
$("input[type='radio']").checkboxradio("refresh");
$('#radio-choice-h-28a').checkboxradio("refresh");
});

$("#reset").click(function () {
$("input[type='radio']").attr("checked", false).checkboxradio("refresh");
$("input[type='radio']").checkboxradio("refresh");
});
});
</script>  

我可以第一次通过设置radio的值,第一次通过reset所有radio按钮

当我第二次点击设置按钮时,没有任何反应。 第一次点击后,第二次点击重置也不会触发。

firebug 不显示任何错误消息,但每次单击按钮(设置和重置)时都会命中断点

我错过了什么?

尝试使用

$(document).on('click', "#set", function(){

});

而不是

$("#set").click(function() { });

找到了....

我将 attr 更改为 prop,现在可以使用了...

$("#radio-choice-h-28a").prop("checked", true).checkboxradio("refresh");