Javascript 选中复选框时禁用单选按钮组jquery

Javascript 选中复选框时禁用单选按钮组jquery,javascript,jquery,html,checkbox,Javascript,Jquery,Html,Checkbox,大家好,我这里有我的代码,我认为它是正确的,应该可以正常工作,但它没有。我有一个单选按钮组和一个复选框。每个单选按钮都有一个值,将用作金额,而复选框仅用于启用文本框,允许用户输入他们想要的金额。我使之成为可能通过检查是否已首先选中文本框来启用文本框。我想在复选框启用时禁用无线组。 这是我的页面的截图 这是我的html <label class="radio-inline" style="margin-left:15%;" >

大家好,我这里有我的代码,我认为它是正确的,应该可以正常工作,但它没有。我有一个单选按钮组和一个复选框。每个单选按钮都有一个值,将用作金额,而复选框仅用于启用文本框,允许用户输入他们想要的金额。我使之成为可能通过检查是否已首先选中文本框来启用文本框。我想在复选框启用时禁用无线组。 这是我的页面的截图

这是我的html

     <label class="radio-inline" style="margin-left:15%;" >
                            <input type="radio" id="amount_suggest_1" name="montantdon" value="50 000" onFocus="this.blur()"  >
                         50 000</label>
    <label class="radio-inline"><input type="radio" id="amount_suggest_2" name="montantdon" value="25 000" onfocus="this.blur()" >25 000</label>
    <label class="radio-inline"><input type="radio" id="amount_suggest_3" name="montantdon" value="10000" onfocus="this.blur()" >10 000</label>
    <label class="radio-inline"><input type="radio" id="amount_suggest_4" name="montantdon" value="5000" onfocus="this.blur()" >5000</label>
    <label class="radio-inline lastradio"><input type="radio" id="amount_suggest_5" name="montantdon" value="1000" onfocus="this.blur()"  checked>1 000</label>

我不想同时发布数据(收音机的价值和手动输入的金额)。我如何解决这个问题?谢谢

如果我正确理解了问题,我建议:

// binds the change-handler:
$('#autresdon').change(function(){
    // sets the 'disabled' property to false (if the 'this' is checked, true if not):
    $('.radio-inline').prop('disabled', !this.checked);
// triggers the change event (so the disabled property is set on page-load:
}).change();
顺便说一句,使用JavaScript(特别是在jQuery中,在jQuery中,它变得完全不必要)时,不要使用在线/突兀的JavaScript。使用
onFocus
/
onFocus
onchange
onclick
等会造成维护噩梦,并创建一些非常(而且是不必要的)不整洁的HTML

参考资料:


    • 如果我正确理解了这个问题,我建议:

      // binds the change-handler:
      $('#autresdon').change(function(){
          // sets the 'disabled' property to false (if the 'this' is checked, true if not):
          $('.radio-inline').prop('disabled', !this.checked);
      // triggers the change event (so the disabled property is set on page-load:
      }).change();
      
      顺便说一句,使用JavaScript(特别是在jQuery中,在jQuery中,它变得完全不必要)时,不要使用在线/突兀的JavaScript。使用
      onFocus
      /
      onFocus
      onchange
      onclick
      等会造成维护噩梦,并创建一些非常(而且是不必要的)不整洁的HTML

      参考资料:


      我喜欢这种方法。如果需要,则无
      。我喜欢这种方法。如果需要,则无
      // binds the change-handler:
      $('#autresdon').change(function(){
          // sets the 'disabled' property to false (if the 'this' is checked, true if not):
          $('.radio-inline').prop('disabled', !this.checked);
      // triggers the change event (so the disabled property is set on page-load:
      }).change();