Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

checked="checked" not rendering as checked radio button in Chrome

If I insert some html via js after the doc.ready than checked='checked' radio button doesn't render as checked in Google Chrome

also, I noticed that if I remove the name attribute from the input than it works

here is the whole thing:

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"
type="text/javascript"></script>
</head>
<body>

<script type='text/javascript'>
$(function(){
$('body').append('<input type="radio" checked="checked" value="33" name="whatever" id="aeHobby0">');

});
</script>
</body>
</html>
like image 492
Omu Avatar asked Jul 26 '11 13:07

Omu


People also ask

Does checked work for radio buttons?

The checked property sets or returns the checked state of a radio button. This property reflects the HTML checked attribute.

How do I mark a radio button as checked?

You can check a radio button by default by adding the checked HTML attribute to the <input> element. You can disable a radio button by adding the disabled HTML attribute to both the <label> and the <input> .

How check if radio is checked jQuery?

We can check the status of a radio button by using the :checked jQuery selector together with the jQuery function is . For example: $('#el').is(':checked') . It is exactly the same method we use to check when a checkbox is checked using jQuery.


1 Answers

It would appear to be a bug in 1.4.4 (live copy). It works fine in 1.6.2 (live copy). Looks like it was fixed between 1.5.2 and 1.6.0 (at least in my tests), which suggests it was probably fixed by the patch that fixed bugs 8060 and 8500.

like image 105
T.J. Crowder Avatar answered Sep 28 '22 04:09

T.J. Crowder