Jquery 选择器css3:选中在IE8中不工作(使用ie7.js)

Jquery 选择器css3:选中在IE8中不工作(使用ie7.js),jquery,html,css,internet-explorer-8,checked,Jquery,Html,Css,Internet Explorer 8,Checked,我有这样的单选按钮: <input class="check" type="radio" id="radio1" name="group"/> <label for="radio1">vrai</label> <input class="check" type="radio" id="radio2" name="group"/> <label for="radio2">faux</label> <input class

我有这样的单选按钮:

<input class="check" type="radio" id="radio1" name="group"/>
<label for="radio1">vrai</label>
<input class="check" type="radio" id="radio2" name="group"/>
<label for="radio2">faux</label>
<input class="check" type="radio" id="radio3" name="group"/>
<label for="radio3">75</label>
<input class="check" type="radio" id="radio4" name="group"/>
<label for="radio4">18</label>

不确定是否必须这样做,但我将重写以下内容,看看它是否改变了某些内容:

$('input').not('input:checked').removeClass("selected");
$(this).addClass("selected");
尝试使用
change()
而不是
click()

$(文档).ready(函数(){
$('input:checked').addClass(“selected”);
$('input').change(函数(){/Hy,
我已经为您制作了纯javascript解决方案,它可以在所有浏览器上运行。请看一下它是否对您有用

         <script type="text/javascript">
                function check(selected)
                {
                  var inputs= document.getElementsByTagName('input');
                  for(i=0 ; i < inputs.length; ++i)
                  {

                       inputs[i].className="";
                  }
                  selected.className="selected";
                }
        </script>

        <input class="check" type="radio" id="radio1" name="group" onclick="check(this);"/>
        <label for="radio1">vrai</label>
        <input class="check" type="radio" id="radio2" name="group" onclick="check(this);"/>
        <label for="radio2">faux</label>
        <input class="check" type="radio" id="radio3" name="group" onclick="check(this);"/>
        <label for="radio3">75</label>
        <input class="check" type="radio" id="radio4" name="group" onclick="check(this);"/>
        <label for="radio4">18</label>

功能检查(选定)
{
var inputs=document.getElementsByTagName('input');
对于(i=0;i
你应该尝试使用onchange事件,而不是我应该在哪里使用onchange?对于
ie7.js
:checked
选择器在ie7/8中应该可以很好地工作,与你正在做的事情完全相同。与其单击,不如使用change,看看这是否有什么区别。我知道在旧IE中使用click for复选框可能会导致问题,但不确定是否有问题收音机,所以试试吧,如果你只是在使用jQuery的
:选中了
,你就不需要ie7.js;jQuery应该在计算选择器。事实上,jQuery甚至不会使用ie7.js,即使你把它包括在你的站点中;如果你在CSS代码中直接使用选择器,ie7.js只会在这种情况下发挥作用。因为IE8不起作用无法识别在IE8中仍然无法更改的伪选择器。我知道伪选择器,这就是我使用IE7.js(谷歌服务)的原因嗨,谢谢你的解决方案,但它在IE8中仍然无法工作=/不知道如何修复它。
$(document).ready(function() {
    $('input:checked').addClass("selected");
    $('input').change(function () {       // <--- HERE
        $('input:not(:checked)').removeClass("selected");
        $(this).addClass("selected");
    });
});
         <script type="text/javascript">
                function check(selected)
                {
                  var inputs= document.getElementsByTagName('input');
                  for(i=0 ; i < inputs.length; ++i)
                  {

                       inputs[i].className="";
                  }
                  selected.className="selected";
                }
        </script>

        <input class="check" type="radio" id="radio1" name="group" onclick="check(this);"/>
        <label for="radio1">vrai</label>
        <input class="check" type="radio" id="radio2" name="group" onclick="check(this);"/>
        <label for="radio2">faux</label>
        <input class="check" type="radio" id="radio3" name="group" onclick="check(this);"/>
        <label for="radio3">75</label>
        <input class="check" type="radio" id="radio4" name="group" onclick="check(this);"/>
        <label for="radio4">18</label>