public

  • Download Gist
really annoying IE radio name bug.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
 
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Really annoying IE6/7 radio name bug</title>
<script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(function() {
// Create some using clone
for(var i=0; i<3; i=i+1) {
$("input[name='template']").clone()
// Set a unique name
.attr("name", "input-" + $("input").length)
.appendTo("body");
}
$("<p/>").text("Now we'll use outerHTML to add some:").appendTo("body");
// Create some using outerHTML
for(var i=0; i<3; i=i+1) {
var newRadioHTML = $("input[name='template']").attr("outerHTML");
newRadioHTML = newRadioHTML.replace('template','input-' + $("input").length);
$("body").append(newRadioHTML);
}
 
$("input").live("click", function() {
$("<p/>").text($(this).attr("name") + " clicked").appendTo("body");
});
});
</script>
</head>
<body>
<input name="template" type="radio">
<p>Here we should have a bunch of independently checkable radio buttons:</p>
</body>
</html>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.