Pregunta

I have two radio buttons on my form and up until I started using jQuery 1.6 the following code worked fine:

<input type="radio" id="radio1" name="test"/>
<input type="radio" id="radio2" name="test"/>
<input type="button" onclick="testcheck()" value="Test"/>
<script>
function testcheck()
{
    if (jQuery("#radio1").attr("checked"))
        alert("first button checked");
    else if (jQuery("#radio2").attr("checked"))
        alert("second button checked");
    else
        alert("none checked")      
}
</script>

Once I start using jQuery 1.6, it always shows "none checked" because jQuery(radiobutton).attr("checked") is always empty.

Take a look at this jsfiddle, and change jQuery version between 1.5.2 and 1.6 to see what I mean.

No hay solución correcta

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top