my site's radio buttons don't work in IE

is there any way to make this work in IE? I am trying to style a survey and it just will not work in IE6 the hover over is fine but the checked just dosen't work

css:

.A label {
    display:inline-block;
    background-color:#F36;
    padding:4px 11px;
    font-family:Arial;
    font-size:16px;
    width:775px;
    text-align:center;
    margin-left:auto;
    margin-right:auto;
}

.A label:hover{
    background-color: #C36;
}

.A input[type="radio"]:checked + label {
    background-color: #C36;
}

Html:

<div class="A">
 <input type="radio" name="price" value="1" id="1PR" checked="checked" /><label for="1PR">£0-2</label><br />
 <input type="radio" name="price" value="2" id="2PR" /><label for="2PR">£3-£5</label><br />
 <input type="radio" name="price" value="3" id="3PR" /><label for="3PR">£6-£8</label><br />
 <input type="radio" name="price" value="4" id="4PR" /><label for="4PR">£9-£11</label><br />
 <input type="radio" name="price" value="5" id="5PR" /><label for="5PR">£12-£14</label>
</div>

Answers


The :checked pseudoclass was not supported until IE9.

For earlier versions of IE, there's no way to do it with pure CSS. You need to use Javascript to add a class when the radio button changes. Here is an example using jQuery:

$(document).ready(function() {
    $('input[type="radio"]:checked').addClass("checked");
    $('input[type="radio"]').change(function() {
        var $this = $(this);
        $("input.checked").removeClass("checked");
        if ($this.prop("checked")) {
            $this.addClass("checked");
        }
    });
});

You can see this code in action here: http://jsfiddle.net/4RnbZ/1/


:checked css selector is not supported before IE9


Need Your Help

Gallery Activity Crashing?

android xml android-activity

Other Activities in my application are opening and changing just fine, but for some reason this one specifically is crashing. Any idea what my issue is?

Updating appointments using EWS

c# exchange-server ews

I'm creating an application which will put a CSV file into Exchange, which works perfectly.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.