简体   繁体   English

输入:选中在 IE9 中不起作用

[英]Input:checked doesn't work in IE9

I made a simple modal that adds a series of records into some tables.我做了一个简单的模态,将一系列记录添加到一些表中。
Before submitting the values I ask the user to check a radio to confirm the action.在提交值之前,我要求用户检查收音机以确认操作。
When the radio is checked the submit button becomes clickable.检查收音机后,提交按钮变得可点击。
This works fine almost in every browser except for IE9 (and previous): in this browser I have to check the radio and then click on a blank point into the modal and only then the submit button becomes clickable.除了 IE9(和以前的)之外,这几乎在每个浏览器中都可以正常工作:在这个浏览器中,我必须检查收音机,然后点击一个空白点进入模态,然后提交按钮才变得可点击。
This is a screenshot of the modal:这是模态的屏幕截图:

在此处输入图片说明



And this is the portion of the code interested:这是感兴趣的代码部分:

 function checkAcconsento() {
    var acconsento = document.querySelector('input[name=acconsento]:checked').value;
    if (acconsento == 'S') {
        document.getElementById('btn_ins_corso').disabled = false;
        document.getElementById('btn_ins_corso').className = "btn_normale";
    } else {
        document.getElementById('btn_ins_corso').disabled = true;
        document.getElementById('btn_ins_corso').className = "";
    }
}


You an try the following, depending on different version of Jquery and browser 您尝试以下操作,具体取决于Jquery和浏览器的不同版本

$('#element').is(':checked');
$('#element').attr('checked');

I have created a plunker here https://plnkr.co/edit/e3pcEO8mUIdomp4YxYrw?p=preview This works for me in IE 11.0.9 I have changed your method to this: 我在这里https://plnkr.co/edit/e3pcEO8mUIdomp4YxYrw?p=preview创建了一个插件。这在IE 11.0.9中对我有效,我将您的方法更改为:

function checkAcconsento() {
    var acconsento = document.querySelector('input[name=acconsento]:checked');
    if (acconsento)
    {
      var val = acconsento.value;
      if (val == 'on') {
          document.getElementById('btn_ins_corso').disabled = false;
          document.getElementById('btn_ins_corso').className = "btn_normale";
      }   
    }
    else {
        document.getElementById('btn_ins_corso').disabled = true;
        document.getElementById('btn_ins_corso').className = "";
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM